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

Cse102 Questions Part1 2024

The document provides 10 sample questions about algorithms and data structures. The questions cover topics like sorting algorithms, circuit design, assembly language, algorithm complexity analysis, and binary search trees. Full solutions or answers are not provided for the questions.

Uploaded by

kimyir2
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)
17 views2 pages

Cse102 Questions Part1 2024

The document provides 10 sample questions about algorithms and data structures. The questions cover topics like sorting algorithms, circuit design, assembly language, algorithm complexity analysis, and binary search trees. Full solutions or answers are not provided for the questions.

Uploaded by

kimyir2
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

Sample Questions – Part 1

No submission required.

1. Write the data list that results from running the shuffle-left algorithm to clean up the following data.
Find the exact number of copies done. [ 3 0 0 2 6 7 0 0 5 1 ]

2. Using the sum-of-product circuit construction algorithm, design a circuit using only AND, OR, and
NOT gates to implement the following truth table. Provide a Boolean expression formula and draw a
circuit design.

a b output
0 0 1
0 1 1
1 0 0
1 1 1

3. Using the instruction set, translate the following algorithmic primitives into assembly language code.
Show all necessary .DATA pseudo-ops.

- Add 3 to the value of K

4. Using the same instruction in Question 3, write a complete assembly language program (including all
necessary pseudo-ops) that reads in a series of integers, one at a time, and outputs the largest and
smallest values. The input will consist of a list of integer values containing exactly 100 numbers.
5. A student was asked to develop an algorithm to find and output the largest of three numerical values x,
y, and z that are provided as input. Here is what was produced:

Input: x, y, z
Algorithm:

Check if (x > y) and (x > z). If it is, then output the value of x and stop. Otherwise,
continue to the next line.

Check if (y > x) and (y > z). If it is, then output the value of y and stop. Otherwise,
continue to the next line.

Check if (z > x) and (z > y). If it is, then output the value of z and stop.

Is this a correct solution to the problem? Explain why or why not.

6. Draw the tree structure that describes binary search on the eight-element list:

Arturo, Elsa, JoAnn, John, Jose, Lee, Snyder, Tracy

What is the number of comparisons in the worst case? Give an example of a name for the worst case.

7. A tennis tournament has 342 players. A single match involves 2 players. The winner of a match will
play the winner of a match in the next round, whereas losers are eliminated from the tournament. The 2
players who have won all previous rounds play in the final game, and the winner wins the tournament.
What is the total number of matches needed to determine the winner? Please consider the following two
questions.

Here is one algorithm to answer this. Compute 342/2 = 171 to get the number of matches in the first
round, which results in 171 winners to go on to the second round. Compute 171/2 = 85 with 1 left over,
which results in 85 matches in the second round and 85 winners, plus the 1 left over, to go on to the
third round. For the third round compute 86/2 = 43, so the third round has 43 matches, and so on. Finish
this process to find the total number of matches.

8. If we were to run the sequential search algorithm many times, with random input values occurring at
various places in the list, we would find the average number of comparisons done to be approximately
n/2.

Answer: True or False

9. If an Θ(n2) algorithm and an Θ(n) algorithm exist for the same task, then for large enough n, the Θ(n2)
algorithm does more work and takes longer to execute, regardless of the constant factors for peripheral
work.

Answer: True or False

10. What is the output after the following code is executed?

1. low = 1
2. high = 20
3. while low < high:
4. print (low, “ ”, high)
5. low = low + 1
6. high = high – 1

You might also like