0% found this document useful (0 votes)
59 views

Algorithm and DS Sample Exam

The document summarizes fundamentals of data structures and algorithms. It includes questions about operations on common data structures like stacks and queues. It asks to represent a graph using an adjacency matrix and determine shortest path between nodes using BFS. It asks to choose best data structures for different scenarios. It also includes questions about algorithms like bubble sort, finding size of linked list, determining average shortest distance in a graph and counting redundant keys in arrays and linked lists.

Uploaded by

Amir Eyni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Algorithm and DS Sample Exam

The document summarizes fundamentals of data structures and algorithms. It includes questions about operations on common data structures like stacks and queues. It asks to represent a graph using an adjacency matrix and determine shortest path between nodes using BFS. It asks to choose best data structures for different scenarios. It also includes questions about algorithms like bubble sort, finding size of linked list, determining average shortest distance in a graph and counting redundant keys in arrays and linked lists.

Uploaded by

Amir Eyni
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Addis Ababa Institute of Technology

Center of Information Technology and Scientific Computing


Fundamentals of Data Structures and Algorithms

1. Show the results of the following sequence of events, by drawing the state of the data structure:
add(4), add(8), add(1), add(6), remove(), remove()
where add and remove are the operations that correspond to the basic operations in the data
structure:

a. Stack
b. Queue (using circular array)

2. Given the graph


a. Represent the following graph using an
adjacency matrix and try to analyze
properties of the graph from the matrix

b. Determine the shortest distance


between node C and node D using the steps
followed by the BFS algorithm

3. For each of the following scenarios choose the “best” data structure from the following list or a
combination of data structures: an unsorted array, linked list, stack, queue. In each case
a. Suppose that a grocery store decided that customers who come first will be served first
b. A list must be maintained so that any element can be accessed randomly
c. A program needs to remember operations it performed in opposite order
d. The size of a file is unknown. The entries need to be entered as they come in. Entries
must be deleted when they are no longer needed. It is important that structure has
flexible memory management

4. Write a pseudocode for an algorithm that determines the size of a linked list
5. What is the total number of swaps needed to sort the list of numbers given below using a
bubble sort?
6, 7, 3, 9, 2, 9, 3, 4, 2, 8, 8
6. Using the graph given above, the distance of node E is 0 and the distance of node A is 3. What is
average number of shortest distance required to find a node chosen at random
7. Determine the big-O of the following operations
a. Removing the 3rd node of a linked list
b. Averaging the values stored in a linked list
8. Write a pseudocode for an algorithm the number of redundant appearance of a given key as an
input if the data structures used is
a. An array
b. A singly linked list

You might also like