50% found this document useful (2 votes)
142 views2 pages

Data Structures & Algorithms Exam Guide

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

Data Structures & Algorithms Exam Guide

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

POKHARA COLLEGE OF MANAGEMENT

Affiliated to Pokhara University


GYAN MARG, NADIPUR, POKHARA-3
Level: Bachelor Term End Internal Exam Year : Spring-2024
Program: BCSIT Full Mark: 100
Semester: 2nd Pass Mark: 45
Course: Data Structure & Algorithm (CMP:176) Time: 3hrs
Candidates are required to give their answers in their own words as far as
practicable. The figures in the margin indicate full marks.

Section “A”
Very short answer questions
Attempt all question [10X2=10]
1. What is data structure? Explain Abstract data type (ADT) with an
example
2. What is time complicity?
3. What are the main features of stack?
4. What is a binary tree?
5. What is hashing?
6. What is a priority queue?
7. Differentiate between external sorting and internal sorting?
8. What is a graph?
9. What is Dynamic Programming?
10. What is linked list?
Section “B”
Descriptive answer Questions
Attempt Any Five question [5X10=30]
11. What is recursive algorithm? write a recursion algorithm for tower
of Hanoi problem
12. Convert the infix expression a+b*c+(d*e+f)*g into infix
expression.
13. Write down algorithm Enqueue and Dequeue operation.
14. How to creates single linked list with examples.
15. Load the key 9,50, 700, 76, 85, 92, 73 81and 101 in this order, a
hash table of size 7 using quadratic probing with c[i]=i 2 and the
hash function h(key)%7
16. To construct the binary tree considering the following sequences:
a. Pre-order:10,5,6,20,30,25,23,24,26,40
b. In-order :5,6,10,20,23,24,25,26,30,40

Section “C”
Long answer questions
Attempt any two questions [(7.5+7.5) X 2= 30
17. a. Insert sequentially AVL tree5,6,8, 3,2,4,7.
b. Write the sequence of node of given tree in pre-order, post-
order and in-order.

18. a. Sort the following sequence of array 2,6,11,4,5,7 using concept


of merge sort. Show each step involved while sorting.
b. writes down the algorithm of bubble sort?

19. a. Using Dijkstra’s Algorithm, find the shortest distance from


source vertex ‘S’ to remaining vertices in the following graph
Also, write the order in which the vertices are visited.

b. What is the differentiate between DFS and BFS?

Common questions

Powered by AI

An Abstract Data Type (ADT) plays a crucial role in data structures by providing a high-level description of the data and the operations that can be performed on it, without requiring knowledge of the implementation details. For example, a stack can be considered an ADT that operates in a LIFO (Last In, First Out) manner, with operations such as push, pop, and peek. Specific implementations of a stack, such as using arrays or linked lists, can differ, but the ADT defines the stack's behavior universally. This abstraction allows programmers to use these data structures effectively without needing to understand their internal workings.

Linked lists offer several advantages over arrays, such as dynamic size adjustments and efficient insertions or deletions, as nodes can be easily added or removed without reorganizing other data. However, they have disadvantages, including greater memory usage due to additional pointers and slower access times, as elements must be accessed sequentially from the head. Arrays, on the other hand, provide fast access through indexing and better memory locality but require size specification at creation time and costly reorganizations for insertions or deletions. The choice depends on the specific needs concerning memory and algorithm efficiency.

Dynamic programming is an algorithm paradigm that solves complex problems by breaking them down into simpler subproblems, storing the results of these subproblems to avoid redundant calculations. This approach differs from other paradigms, like divide and conquer, by focusing on the overlapping subproblems and optimal substructure, making it particularly suited for problems such as the knapsack problem, Fibonacci sequence, and shortest path problems where repeated calculations can be minimized. Dynamic programming excels in scenarios requiring optimization and efficient recalculations.

DFS uses a stack-based approach, either explicitly or through recursion, exploring as far as possible before backtracking. This makes it memory-efficient in sparse graphs but can lead to deep recursions and potential stack overflow in expansive trees. It is advantageous in path finding or connectivity checks without concern for the shortest path. BFS, using a queue, ensures visits in layer-order, providing the shortest path in unweighted graphs but consuming more memory due to keeping track of all nodes at current layer depth. The choice depends on specific use-case requirements of memory vs. path optimality.

Time complexity is a measure of the amount of computational time that an algorithm takes to complete as a function of the length of the input. It affects algorithm efficiency by providing a way to predict how an algorithm will scale with increasing input sizes. For example, a linear time complexity algorithm, denoted as O(n), is generally more efficient than a quadratic time complexity algorithm, O(n^2), when dealing with large datasets. Time complexity helps in selecting the most appropriate algorithm for a given problem to optimize performance and resource usage.

A priority queue is a data structure where each element has a priority assigned to it, and elements with higher priority are served before those with lower priority. One common implementation of a priority queue is using a binary heap, where the maximum (or minimum) element can be accessed in constant time, and insertion and deletion operations are performed in logarithmic time. The binary heap ensures that the tree is always balanced, preserving efficiency, and making it suitable for scheduling and simulation tasks.

A binary tree is a type of tree data structure in which each node has at most two children, referred to as the left child and the right child. This structure differs from other trees, where nodes can have multiple children. Binary trees are widely used in computer science due to their efficient data organization that facilitates fast search, insertion, and deletion operations. They form the basis of several important data types, including binary search trees, heaps, and binary decision diagrams, making them crucial for algorithm design and database indexing.

External sorting is used when the data to be sorted does not fit into the main memory, relying on external storage such as disk drives. Internal sorting occurs entirely within the main memory. The key difference is based on the size of the data. External sorting, like merge sort, is used for very large datasets that exceed RAM capacity. Internal sorting, such as quicksort and bubble sort, is used when data fits into memory, offering faster sorting times due to direct data access. The choice depends on dataset size and available resources.

The main features of a stack data structure include its LIFO (Last In, First Out) nature, where the last element added to the stack is the first one to be removed. Key operations include push (adding an item), pop (removing the top item), and peek (viewing the top item without removal). Stacks are important in computational tasks such as recursive function management, expression parsing, and reversing data due to their ability to efficiently manage order-sensitive operations and maintain state information within a constrained context.

Dijkstra's algorithm finds the shortest path from a source vertex to all other vertices in a graph by iteratively selecting the node with the minimal distance and updating the path estimates for its neighbors. Its limitation lies in its inability to handle graphs with negative weight edges, as it assumes that once a vertex's shortest path is determined, no shorter path will be found. Additionally, its performance can degrade with dense graphs due to higher computational complexity, and alternatives like Bellman-Ford are preferred for graphs with negative weights.

You might also like