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

Assign 1 Data Struct PDF

The document outlines an assignment on data structures and algorithms for a university course. It contains 4 questions - the first asks to sort an array, the second describes data structures and compares sorts, the third implements sorting algorithms on a list and uses a stack, the fourth generates Fibonacci numbers.

Uploaded by

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

Assign 1 Data Struct PDF

The document outlines an assignment on data structures and algorithms for a university course. It contains 4 questions - the first asks to sort an array, the second describes data structures and compares sorts, the third implements sorting algorithms on a list and uses a stack, the fourth generates Fibonacci numbers.

Uploaded by

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

CHINHOYI UNIVERSITY OF TECHNOLOGY

SCHOOL OF ENGINEERING SCIENCE


AND TECHNOLOGY

DEPARTMENT OF ICT AND ELECTRONICS

COURSE: DATA STRUCTURES AND ALGORITHMS (Assignment One)

CODE: CUIT 205

DUE DATE: 11 April 2023

INSTRUCTIONS TO CANDIDATES:

Code in Python

No copying
Question 1

Write a code which sorts an array containing only 0's, 1's and 2's

INPUT { 0,1,2,2,1,0,0,2,0,1,1,0}

OUTPUT {0,0,0,0,0,1,1,1,1,2,2,2} [6]

Question 2

a) Describe the major data structures used in the following areas: [6]

RDBMS, Network data model, and Hierarchical data model


b) Compare the quick-sort and merge-sort algorithms in terms of their time and space
complexity. [4]

c) Indicate what will be printed by the final line of code

int[] a = {10, 8, 6, 4, 2};


int[] b = {10, 8, 6, 4, 2};
int[] c = a;
for (int i = 0; i<b.length; i++)
c[i] = b[i];
b[3] +=b.length;
a[3]--;
System.out.println(a[3] + “ “ + b[3] + “ “ + c[3]); [3]

d) A police department wants to maintain a database of up to 1800 license-plate numbers of


people who receive frequent tickets so that it can be determined very quickly whether or
not a given license plate is in the database.

Describe the type of data structure that would be appropriate for this type of task. [5]

Question 3

a) Given a list of numbers below in table 3


8 12 3 17 20 1 4 15

Table 3

Sort the numbers using the following techniques:


(i) Shell sort [4]

(ii) Selection sort [4]

(iii) Insertion sort [4]

b) Write a program that implements [6]

A stack using an array with the following output

Output
Element at top of the stack: 9
Elements:
9
3
4
Stack full: false
Stack empty: true

Question 4

a) Write a code which gives the following output [3]

b) Write a program that implements the Fibonacci series [5]

You might also like