0% found this document useful (0 votes)
174 views2 pages

Assignment 2 - DS

This document outlines assignments for a data structures course divided into four units: stacks, queues, and recursion; sorting, searching, and hashing; trees; and binary trees. The assignments include problems involving converting infix to postfix expressions, evaluating postfix expressions, sorting arrays with different algorithms, hashing with collision resolution techniques, tree traversals, heap operations, binary search trees, and counting nodes in binary trees. Students are to complete 10 problems for each unit, covering fundamental data structures concepts.

Uploaded by

itskanishka1202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
174 views2 pages

Assignment 2 - DS

This document outlines assignments for a data structures course divided into four units: stacks, queues, and recursion; sorting, searching, and hashing; trees; and binary trees. The assignments include problems involving converting infix to postfix expressions, evaluating postfix expressions, sorting arrays with different algorithms, hashing with collision resolution techniques, tree traversals, heap operations, binary search trees, and counting nodes in binary trees. Students are to complete 10 problems for each unit, covering fundamental data structures concepts.

Uploaded by

itskanishka1202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT 2

SUBJECT: DATA STRUCTURE (BCS301)


DUE DATE: MONDAY 11, DEC 2023

UNIT 2 – STACK, QUEUE AND RECURSION


1. Convert the following infix expression into postfix expression using stack.
A*(B+D)/E-F*(G+H/K)
2. Write an algorithm to evaluate postfix expression also find the value of
7,5,2,-,*,4,1,5,-,/,+.
3. Write an algorithm for converting infix expression into postfix expression. Trace
your algorithm for infix expression Q into its equivalent postfix expression P,
Q: A + ( B * C – ( D / E ^ F) * G ) * H
4. What is the condition if circular queue is full?
5. Show all steps used to solve tower of Hanoi problem for 4 disks.
6. Write recursive and non-recursive functions for
(i) Factorial of a number
(ii) Fibonacci series
(iii) GCD of two numbers

UNIT 3- SORTING, SEARCHING AND HASHING

1. Sort following Elements using Merge sort 45, 32, 65, 76, 23, 12, 54, 67, 22, 87
2. Use quick sort algorithm to sort 15,22,30,10,15,64,1,3,9,2. Is it a stable sorting
Algorithm? Justify.
3. The keys 12, 17, 13, 2, 5, 43, 5 and 15 are inserted into an initially empty hash
table of length 15 using open addressing with hash function h(k) = k mod 10 and
linear probing. What is the resultant hash table?
4. Write a quick sort algorithm. Use quick sort algorithm to sort the following element:
15, 22, 30, 10, 15, 64, 1, 3, 9, and 52
5. Use Heap sort algorithm, sort the following sequence:
18, 25, 45, 34, 36, 51, 43, and 24.
6. Describe various ways to select Pivot element in quick short.
7. Differentiate between linear and quadratic probing techniques.
8. Use the merge sort algorithm to sort the following elements in ascending order.
13, 16, 10, 11, 4, 12, 6, 7. What is the time and space complexity of merge sort?
UNIT 4- TREE
1. Examine the minimum number of interchanges needed to convert the array 90, 20, 41,
18, 13, 11, 3, 6, 8, 12, 7, 71, 99 into a maximum heap
2. For a binary tree T, the preorder and in-order traversal sequences are as follows :
In order: H K D B I L E A F C M J G
Preorder: A B D H K E I L C F G J M
(i) Construct a binary Tree.
(ii) What is its Post-order traversal sequence?
3. Write an algorithm to in-order tree traversal of binary tree. Also Construct the binary
tree of the following given traversal order
In-order : M, E, P, A, Q, T, R, C, F, K.
Post-order: M, P, E, Q, R, C, T, K, F, A.
4. For given sequence of numbers, construct a heap and a BST
34, 23, 67, 45, 12, 54, 87, 43, 98, 75, 84, 93, 31
5. Show the maximum number of node in a binary tree of height h is 2h+1- 1.
6. For a binary tree T, the preorder and in-order traversal sequences are as follows :
In order: B C A E G D H F I J
Preorder: A B C D E G F H I J
(i) Construct a binary Tree.
(ii) What is its post-order traversal sequence?
7. The order of nodes of a binary tree in inorder and postorder traversal are as follows:
In order: B, I, D, A, C, G, E, H, F.
Post order: I, D, B, G, C, H, F, E, A.
(i) Draw the corresponding binary tree.
(ii) Write the pre order traversal of the same tree.
8. Construct an expression tree for the following algebraic expression.
(3a-b) ↑2(4c+2d) ↑3
9. Construct an Binary Search tree by inserting the following elements in the order of
their occurrence: 60, 2, 14, 22, 13, 111, 92, 86. Also delete 60 and 14.
10. Write functions to:
i. Count leaf nodes in Binary Tree
ii. Find maximum in a Binary Tree
iii. Count One child Node in Binary Tree

You might also like