Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

HCT108 PRACTISE & RESEARCH QUESTIONS

1. Explain any three reasons why algorithm designers should be concerned


with the concept of Big O.

2. What is meant by the efficiency of an algorithm? How can you compare


the efficiency of two algorithms? Explain the concept of best case, worst
case and average case time complexity.

3. With the aid of relevant examples discuss the following hypothesis about
data structures “the structure of the data affects what can be done
efficiently with the data”

4. The data structure philosophy states that “Each data structure has costs
and benefits that rarely is one data structure better than another in all
situations”. With the aid of relevant examples and comparing different
data structures support or refute the above philosophy.

5. Write a C++ program that shows all the basic array operations such as
searching, insertion, deletion, retrieval, traversal etc. on a one and two
dimensional array.

6. Write a program in C++ to create two arrays to store Reg numbers and
marks for students whose total number would be known at runtime

7. What is the primary conceptual difference between a stack and a queue?

8. Briefly describe how to efficiently implement a stack using a linked list

9. Research on basic queue applications and write a C++ program that


shows the array implementation of a queue showing all the queue
operations in the main of that program.
10. Discuss the array and linked list implementation of a queue data
structure.

11. Given a list of objects stored in a sorted linked list, describe an algorithm
to insert a new object as efficiently as possible while keeping the list
sorted. You may describe your algorithm in English, pseudocode, and/or
C++ code, as long as your description is clear

12. Discuss the array representation of stacks showing the push and pop
stack operations

13. Taking a queue containing numbers 10, 15, 5, 25 and 30 in which 30 has
been inserted first. After performing the following operations what will
be the contents of the queue? (a) delete two elements (b) insert 7 and
then 20 (c) delete an element? With the aid of diagrams where necessary
show how you arrive at your answer.

14. Research on basic linked listed applications and Write a C++ program that
shows the Implementations of Lists Using Arrays.

15. Write a C++ program that shows the array implementation of a stack
showing all the basic stack operations in the main of that program.

16. Research on how to change expressions from infix to postfix using the
stack implementation

17. Convert the following infix to postfix using the stack implementation and
solve the postfix expression also using the stack implementation
(a + b) / (c –d) * (e + f)
((a – b) * (c + d)) / (e + f) * (g + h)
Where a= 7, b = 4, c=10, d=20, e= 11, f=5, g=2, h =3
18. Change the following infix expression to a postfix expression using the
addition of parentheses ( ).
(i) ((a+b)/d-((e-f)+g)
(ii) 12/3*6+6-6+8/2

19. Change the following infix expression to a prefix expression using the
addition of parentheses ( ).
(i) ((a+b)/d-((e-f)+g)
(ii) 12/3*6+6-6+8/2 12

20.Below are given postfix expressions. Using the postfix expression


evaluation algorithm, evaluate the expressions.
(a) 21 3 / 10 - 7 3 / *
(b) 3 5 * 2 6 - *

21. Discuss in detail where it will be best to apply the following data
structures: binary search trees, queues, sorted linked lists, sorted arrays,
and a hash table using open addressing

22. Research on Binary Search Trees (BST) focusing mainly on how to create
them, search them, insert nodes into them, traverse them, delete nodes
from them and lastly their basic applications

23. Form the binary tree for which the following are given:

Inorder traversal: f h i g b a d e c
Preorder traversal: a b f g h i c d e
24. The following is a binary tree:

14
/ \
2 11
/ \ / \
1 3 10 30
/ /
7 40

Write the order of the nodes visited in a post-order traversal.


25.

26.
27. Insert the following numbers into a binary search tree in the order that
they are given and draw the resulting tree. 14; 34; 22; 44; 11; 24; 33; 90

28.Suppose the keys on the middle row of a standard keyboard


(ASDFGHJKL) are inserted in succession into an initially empty binary
search tree. Draw the tree after this sequence of insertions has been
made.

29.Create a binary tree using inorder and preorder traversal


Inorder: D B H E A I F J C G,
Preorder: A B D E H C F I J G.

30. Compare and contrast sequential searching to binary searching


and also look at the different application of both searches. Lastly write
C++ programs that shows the implementations of both searches.

31. Research on the following sorting techniques, discussing their pros and
cons and where best they can be applied: merge sort, bubble sort, quick
sort, simple selection sort and linear insertion sort. Lastly look into how
they can all be implemented using arrays.

32. Write an algorithm for quick sort. Also apply the algorithm to the
following sequence: 25, 10, 30, 15, 20, 28, 18, and 12 showing all the
intermediatory steps.

33. Sort the following list using the merge sort : 8,2,4,6,9,7,10,1,5,3

34.Show the steps of bubble and shell sort algorithm on the following list of
unsorted integers. 21; 75; 29; 2; 15; 23; 221; 7; 88; 195
35. Why is quick sort named as “quick”? Show how the following data set
can be sorted by quick sort: 78, 23, 11, 88, 43, 55, 67 and 55 showing each
step in sorting.

36. An array contains these elements: 13, 17, 97, 44, 8, 56, 26, 88
a. Use quick sort to show the steps needed to sort the array
b. On the sorted array use the binary search algorithm to trace the
steps followed to find the element 88
c. How many number of steps do you need to search the above array
using the binary search algorithm

37. Write an algorithm/ program for the following:


i. Bubble sort
ii. Selection sort
iii. Insertion sort
iv. Quick sort
v. Merge sort

38. Show the steps of quick sort algorithm on the following list of
unsorted integers. Assume that the pivot node is always the one on the
left hand side of the list. Box all pivots and underline all numbers that
have been placed in their correct respective positions.

E; X; A; M; P; L; E; S; I
39. Computer science department want to come up with an
innovation hub. Students in level 2 who develop good projects are
rewarded by having their projects showcased in the hub. The projects are
done in teams not exceeding 4. Marks awarded by the panel of lecturers
are used to determine the top 3 projects and are awarded $5000, $3000
and $1000 price money respectively. Using an appropriate data type
implement a program to come up with 3 best projects from 10 done by
the level 2 student. You can make any of your assumption but the
program should be able to print the three best projects and the team
members.

40. Using static implementation, write a program that will read 10


numbers one by one from the keyboard and test whether the number is
even or odd. If the number is odd, that number will be inserted into the
odd stack and if the number is even, that number will be inserted into the
even stack and if it is a multiple of 5 it will be inserted into another
multiple stack. The program then prints the contents of three stacks to
the screen. Two elements from the even and odd stack are deleted. Your
program should then display the new stacks without the deleted
elements.

Most of the content in this document we haven’t covered, some we won’t


even cover in class or lecture notes but in 2’s or more try to cover as much
ground as possible as these give a blueprint of almost everything we were
supposed to cover this semester. I intend to post practice and research
questions 2 before you come back on campus. Also occasionally start checking
Tsime and your lms platforms these coming weeks as I will commence posting
lecture notes otherwise be safe and make the most of your time home.
Regards Mr. D. Mapuma

You might also like