0% found this document useful (0 votes)
846 views6 pages

DS Assignment 3rd Sem IPU

This document contains 9 questions related to data structures and algorithms. It asks the student to write algorithms and programs for operations on arrays, linked lists, stacks, queues, trees including binary search trees and AVL trees. It involves tasks like traversing, searching, inserting and deleting nodes from different data structures. The student is expected to solve problems on tree traversals, expression trees, priority queues, sparse matrices and sorting algorithms.

Uploaded by

ykr007
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
846 views6 pages

DS Assignment 3rd Sem IPU

This document contains 9 questions related to data structures and algorithms. It asks the student to write algorithms and programs for operations on arrays, linked lists, stacks, queues, trees including binary search trees and AVL trees. It involves tasks like traversing, searching, inserting and deleting nodes from different data structures. The student is expected to solve problems on tree traversals, expression trees, priority queues, sparse matrices and sorting algorithms.

Uploaded by

ykr007
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 6

Ansal Institute of Technology, Gurgaon

Assignment No. 1
Course Code : ETCS 211 M.M. 20
CourseTitle : Data Structures Lab Due Date: 14/08/10

Q1. A two – dimensional array A [5][4] is stored a row – wise in the memory. The first
element of the array is stored at location 80. Find the memory location of A [3][2] if
the each elements of array requires 4 memory locations.

Q2. A two – dimensional array defined as A [4…7, -1…3] requires 2 bytes of storage
space for each element. If the array is stored in row-major order, then calculate the
address of element at location A [6,2]. Given that the base address is 100.

Q3. A two – dimensional array defined as A [-20…20, 10…35] requires one byte of
storage space for each element. If the array is stored in column -major order, then
calculate the address of element at location A [0, 30]. Given that the base address is
500.

Q4. Write a program to read and write array and copy the contents of array a in array B in
reverse order then find sum of array a and array b and store it in array C.

Q5. Write a program to convert a square matrix to a unit matrix.

Q6. Write a recursive algorithm for Tower of Hanoi problem.

Q7. Write the algorithm for the following sorting.


(a) Bubble sort
(b) Selection sorting

Q8. Write the algorithms for implementing the following operation depending on whether
the operation requires one or two matrices

(a) Addition of two matrices


(b) Subtraction of two matrices
(c) Finding upper and lower triangular matrices
(d) Trace of a matrix
(e) Transpose of a matrix
(f) Check of matrix symmetry
(g) Product of two matrices
Ansal Institute of Technology, Gurgaon
Assignment No. II
Course Code : ETCS 211 M.M. 20
CourseTitle : Data Structures Due Date: 03/09/10

Q1.
(a) What are two main factors for measuring the performance of
algorithm? Explain in brief.
(b) Discuss the tradeoff in between the time and space complexity of a
program.

Q2.
(a) What is sparse matrix? How sparse matrix can be represented in
memory in two different ways?
(b) What is priority queue? How priority queue can be represented in
memory in two different ways?

Q3.
(a) Write an algorithm/program to delete a node with value X from a
singly linked list.
(b) Write a program to reverse a singly linked list without using any more
memory.

Q4.
(a) Write an algorithm/program to create a doubly linked list and traverse
each node in both directions (from start to end and end to start).
(b) Write an algorithm/program for inserting a node at a given location in
circular linked list.

Q5. Write a procedure for multiplication of two polynomials with the help of
an example.
Ansal Institute of Technology, Gurgaon
Assignment No. III
Course Code : ETCS 211 M.M. 20
CourseTitle : Data Structures Due Date: 10/09/10

Q1 Convert the following infix expressions into equivalent postfix and


prefix expressions.
(i) (A + B) / (C * D) (ii) (A + B ^ C) / (D - E) * F
(iii) A / (B + C) * D – E /(F – G * H) (iv) ((A + B) / D) ^ ((E - F) * G)
(v) (A - B) / ((D + E) * F)

Q2. Convert the following infix expressions into postfix using stack
(i) A ^ B * C – D + E / F / (G + H)
(ii) A + (B * C – ( D / E ^ F ) * G ) * H

Q3. Evaluate following postfix expressions using stack


(i) 5 4 6 + * 4 9 3 / + *
(ii) 6 3 + 2 * 6 9 7 - / -

Q4. Construction of the tree from its given preorder and inorder traversal
Preorder: A B D E F C G H J L K
Inorder: D B F E A G C L J H K

Q5. Construction of the tree from its given postorder and inorder traversal
Postorder: D F E B G L J K H C A
Inorder: D B F E A G C L J H K

Q6. Construction of the tree from its given preorder and postorder traversal
Preorder: A B D G H K C E F
Postorder: G K H D B E F C A
Ansal Institute of Technology, Gurgaon

Assignment No. IV
Course Code : ETCS 211 M.M. 20
CourseTitle : Data Structures Due Date: 18/10/10

Q1.

(a) Draw the expression tree for the expression

(a-3b) (2x-y)5 + (e-f)3

(b) Find the preorder & postorder traversal of tree in Q1 (a)


(c) Suppose the following seven numbers are inserted in order into an empty binary
search tree T, then draw the Binary search tree. 50, 33, 44, 77, 35, 60, 40.
(d) What are the threaded binary tree? Discuss their usability.

Q2.

(a) What is AVL tree?. Why height balancing is required?


(b) For the following given sequence of months, create AVL tree(show each step with
all rotations and BF):Jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec
(c) Construct an AVL tree when numbers are inserted as follows:14, 10, 6, 4, 25, 28,
17, 19, 18, 16.
(d) Construct an AVL tree when numbers are inserted as follows: 55, 66, 77, 15, 11,
33, 22, 35, 25, 44, 88, 99.
(e) Construct an AVL tree when numbers are inserted as follows:64, 1, 14, 26, 13,
110, 98, 85.
(f) Construct an AVL tree when numbers are inserted as follows:20, 10, 30, 25, 35, 5,
40, 45,34

Q3.(a) Write a function or algorithm that will delete a node from a binary search tree.

(b) Write a function or algorithm that will insert a node in a binary search tree.

Q4. Explain various traversal techniques of a binary tree. Suppose, following traversed
sequences of a binary tree are given:

(a) Pre-order: 1, 2, 3, 4, 5, 6, 7, 8, 9

In-order: 2, 3, 1, 5, 4, 7, 8, 6, 9

(b) Pre-order: A, B, D, G, C, E, H, I, F

In-order: D, G, B, A, H, E, I, C, F

You might also like