DSA Assignment 1
DSA Assignment 1
Instructions:
• All the students need to mention their name and reg.no at the end of each page of assignment.
• You all need to write the assignment on A4 sheet only.
• Last date to submit the assignment is 10th October 2024 by 4 PM.
1. Define data structure. List the various linear and non-linear data structures and explain them in brief.
(a) Given a two dimensional array A1(1:8, 7:14) stored in row-major order with base address 100 and size
of each element is 4 bytes, find address of the element A1(4, 12).
(b) Given a two dimensional array Z1(2:9, 9:18) stored in column-major order with base address 100 and
size of each element is 4 bytes, find address of the element Z1(4, 12).
4. Convert the infix expression, ((a/(b-c+d))*(e-a)*c) to postfix expression. Write a function to evaluate that
postfix expression and trace for the given data a=6, b=3, c=1, d=2, e=4.
6. State the advantages of circular and doubly linked lists over a singly linked list.
9. Write a C program for mentioned problem: - Given an array nums with n objects colored red, white, or
blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red,
white, and blue.
10. Write a C program for :- Given an integer array nums sorted in non-decreasing order, remove some
duplicates in-place such that each unique element appears at most twice. The relative order of the elements
should be kept the same.
11. Define Time complexity and Space complexity. Calculate time complexity for given expression.
1) A + ( (B – C) * (D – E) + F) / G )
$ (H – J)
2) (A + B) * (C – D) $ E * F
3) (A + B) * (C ^ (D – E) + F) – G
4) A + B * C
5) A + B * C ^ D – E
6) A + [(B +C) + (D + E) * F] / G
7) (A + B) * C / D + E ^ F /G
8) (A + B) * C / D
9) ((A + B – C / D) / E)
10) A / (B – C / D ^ E) + F
1) 5 + 4 * 2
2) 4 + 2 * 5 ^ 2 + 9 / 3 – 1 * 8
3) 40 25 + 20 5 * 3 + *
4) 9 + 5 * 7 – 6 ^ 2 + 9 / 3
5) 8 * 2 -1 + 7 * 5
14. Write down a C program to implement Circular Queue Using Linked List.