0% found this document useful (0 votes)
97 views4 pages

Ics 2105 Data Structures & Algorithm

The document contains a past exam paper for Data Structures and Algorithms from Jomo Kenyatta University of Agriculture and Technology. It consists of 5 questions testing various concepts related to algorithms, data structures, asymptotic analysis and abstract data types. Specifically, it asks students to: 1) Define key terms, write algorithms, and analyze time complexity. 2) Contrast prior and posterior algorithm analysis and asymptotic notations. 3) Demonstrate operations on common data structures like lists, stacks and queues. 4) Provide examples of algorithms and applications of abstract data types. 5) Perform traversals on sample tree structures and trace code implementing array operations.

Uploaded by

123 321
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
Download as rtf, pdf, or txt
0% found this document useful (0 votes)
97 views4 pages

Ics 2105 Data Structures & Algorithm

The document contains a past exam paper for Data Structures and Algorithms from Jomo Kenyatta University of Agriculture and Technology. It consists of 5 questions testing various concepts related to algorithms, data structures, asymptotic analysis and abstract data types. Specifically, it asks students to: 1) Define key terms, write algorithms, and analyze time complexity. 2) Contrast prior and posterior algorithm analysis and asymptotic notations. 3) Demonstrate operations on common data structures like lists, stacks and queues. 4) Provide examples of algorithms and applications of abstract data types. 5) Perform traversals on sample tree structures and trace code implementing array operations.

Uploaded by

123 321
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1/ 4

W1-2-60-1-6

JOMO KENYATTAUNIVERSITY OF AGRICULTURE AND TECHNOLOGY


University Examinations 2020/2021
YEAR II SEMSTER I SPECIAL/SUPPLEMENTARY EXAMINATION FOR THE
DEGREE OF BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY

ICS 2105: DATA STRUCTURES & ALGORITHM

DATE: AUGUST, 2021 TIME: 2 HOURS

INSTRUCTIONS: Answer Question ONE and Any Other TWO Questions.

Question One (30 Marks)

a) i. In your experience in today’s life, where do you think you can apply the concept
of algorithms? Discuss with an example. [6 marks]

ii. Write an algorithm to be used to swap 2 numbers. [2 marks]

iii. Write an implementation of the algorithm you have written in 2 using a high level
language. [3 marks]

b) i. Define the term data structure. [2 marks]

ii. List your characteristics of data structures. [4 marks]

c) Differentiate between prior and posterior analysis of algorithms. [6 marks]

d) i. List and explain the three major asymptomatic notations used to represent the
space/time complexity of an algorithm. [6 marks]

ii. State any three factors that influence the running time of a given algorithm.
[3 marks]

e) i. Evaluate the time complexity of the following code segment. [4 marks]

sum=0
for (i=0;i<n,i+ +){
j=i;
1
for(j=n; j>0;j/2){
sum=sum+i;
}
}

Question Two

a) i. Define a list abstract data type. [2 marks]

ii. Define a stack abstract data type. [2 marks]

iii. Write down an algorithm used to delete an element from a list. [6 marks]

b) i. Write a pseudo code algorithm that prompts the user for 3 integers (N1,N2, and
N3), finds the biggest integer and prints it. [6 marks]

ii. Implement algorithm into a program using a high level language. [4 marks]

Question Three

a) i. Define the term ADT. [2 marks]

ii. Write an algorithm demonstrating the pop and push operations of a stack ADT.
[8 marks]

iii. Briefly explain any 2 applications of a stack ADT. [4 marks]

b) Define what a spanning tree is and hence give its properties. [6 marks]

Question Four

a) i. Write a method/procedure that accepts and unsorted integer array and uses the
merge sort algorithm to sort the array. [10 marks]

ii. Write an algorithm (pseudo code or structural English) to represent the diguue and
Enguue operation. [8 marks]

iii. Explain on use of the queue ADT. [2 marks]

2
Question Five

a) Using the data structure illustrated below, answer the following questions:

i) What types of ADT is displayed above? [1 mark]


ii) Find the root of the above ADT. [1 mark]
iii) Siblings of B. [1 mark]
iv) Pre-order traversal [3 marks]
v) Post-order traversal [3 marks]

b) Consider the following program: # include <stdioh>


void main ( ) {
int LA [ ] = {1,3,5,7,8}
int k=3, n=5;
int i,j;
j=k;
while (j<n) {
LA[j-,J]=LA[J];
J=j+1;
}
n=n-1;
for (i=0; i<n; I + +){
printf (“LA[% d]=% d% \n”,
i, LA[i]);
}
}

What does the above program print? [2 marks]

Dry run to show your answer. [9 marks]

3
4

You might also like