0% found this document useful (0 votes)
120 views6 pages

SEMESTER I, 20152016 Midterm

This document is a mid-term examination for an Algorithms and Programming course consisting of two sections worth 100 marks total. Section A involves algorithm analysis questions regarding time complexity, algorithm definitions, and analyzing code snippets. Section B involves data structures questions about arrays, linked lists, binary trees, binary search trees, and hash tables. The exam is worth 25% of the total course assessment and students are instructed to show their work.
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)
120 views6 pages

SEMESTER I, 20152016 Midterm

This document is a mid-term examination for an Algorithms and Programming course consisting of two sections worth 100 marks total. Section A involves algorithm analysis questions regarding time complexity, algorithm definitions, and analyzing code snippets. Section B involves data structures questions about arrays, linked lists, binary trees, binary search trees, and hash tables. The exam is worth 25% of the total course assessment and students are instructed to show their work.
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/ 6

ECE 3231Algorithms and Programming | Mid-Term Examination | 4 April 2015

Name : Matric No :
Section No: ___________________________

INTERNATIONAL ISLAMIC UNIVERSITY MALAYSIA


Mid-Term Examination
SEMESTER I, 2015/2016 SESSION

KULLIYYAH OF ENGINEERING

Program : Engineering Level of Study : UG 3

Time : 5:00 PM – 7:00 PM Date : 31st March 2016

Duration : 2 Hour

Course Code : ECE 3231 Section(s) : 1

Course Title : ALGORITHMS AND PROGRAMMING

This question paper consists of (5) printed pages (including cover page)
with Two (2) sections.

INSTRUCTION(S) TO CANDIDATES
DO NOT OPEN UNTIL YOU ARE ASKED TO DO SO

 This examination amounts to 25% of the total assessment.


 Answer the questions from all Three (3) sections.
 Write down your answers on these examination sheets.
 Write your name, matric number and section on every answer sheet.
 The total mark of this examination is 100.

Any form of cheating or attempt to cheat is a serious offence which may lead to dismissal.

1
ECE 3231Algorithms and Programming | Mid-Term Examination | 4 April 2015

Name : Matric No :
Section No: ___________________________

Section A: ALGORITHM ANALYSIS (40 Marks)

A1. In algorithm analysis, when the input size increases the algorithm may take time
to compute the result, hence finding the order of growth of the algorithm is very
crucial. Given N as size of array to search for a key K, Use the most
appropriate notation among O, Ɵ, Ω, and θ, to indicate the time efficiency class
of sequential search of a key given
a. in the worst case.
b. in the best case.
c. in the average case.
(3 Marks)

A2. Why is experimental studies not consider efficient when calculating running time
of an algorithm? (2 marks)

A3. Define an algorithm, what are the 2 main components to be considered when

analysing algorithm? (6 marks)

Indicate which function grows at the same rate

A4. In a recent court case, a judge cited a city for contempt and ordered a fine of $2
for the first day. Each subsequent day, until the city followed the judge’s order, the
fine was squared (i.e., the fine progressed as follows: $2, $4, $16, $256, $65,536, . .
.).
a. What would be the fine on day N?
b. How many days would it take for the fine to reach D dollars (a Big-Oh answer
will do)? (4 marks)

A5. By inspecting the pseudocode, answer the following question: (7 marks)

2
ECE 3231Algorithms and Programming | Mid-Term Examination | 4 April 2015

Name : Matric No :
Section No: ___________________________

a. What does this algorithm compute?


b. What is its basic operation in each line?
c. How many times is the basic operation executed (total)?
d. What is the efficiency class of this algorithm?

A6. Indicate the running time of each algorithm or code segment. (10 marks)

(a)
for( i = 0; i < n; ++i )
for( j = 0; j < n; ++j )
++k;

(b) Dequeue an element in a Queue

(c) Consider a dictionary with n items implemented by means of a binary


search tree of height h. the space used is O(n). Methods findElement (),
insertItem () and removeElement() take O(h) time. What is the worst case
and best case of for the height h

(d)
sum = 0;
for( i = 0; i < n; ++i )
for( j = 0; j < n * n; ++j )
++sum;

(d) Inserting element in a LinkedList (InsertFirst()).

A7. Proof that (3 marks)

2n + 10 is O(n)

A8.
Muhammad ibn Musa al-Khwarizmi the great mathematician of 9th century states in
is The Golden Principle of Al-Khwarizmi that all complex problems of science must
be and can be solved by means of five simple steps. Elaborate on these principles
(5 Marks)

3
ECE 3231Algorithms and Programming | Mid-Term Examination | 4 April 2015

Name : Matric No :
Section No: ___________________________

Section B: DATA STRUCTURE AND ABSTRACT DATA TYPE (60 Marks)

B1

a. An array is a sequenced collection of variables all of the same type, however


it has some drawbacks, explain two draw backs of an array and how to
overcome such drawbacks. (6 marks)

An important property of a linked list is that it does not have a predetermined fixed
size;, we can easily insert an element at the head or tail of the list. Write a pseudo-
code in Code Fragment addFirst(e) as shown in Figure 2. to create a new node, set
its element to the new element, set its next link to refer to the current head, and then
set the list’s head to point to the new node (4 marks)

Figure 2

B2. Use figure 1 to answer questions a to f (6 marks)

4
ECE 3231Algorithms and Programming | Mid-Term Examination | 4 April 2015

Name : Matric No :
Section No: ___________________________

Figure 1

(a) What is the parent of node E? ________________________

(b) What is the height of this tree? _________________________

(c) List the sibling(s) of nodes F. ___________________________

(d) List ancestor(s) of nodes. L_____________________________

(e) List all the internal nodes _______________________________

(f) Compute the depth of node D _____________________________

(g) Evaluate the following infix to postfix expression using stack concept (5 marks)

A*B-(C-D)/E

B3. (20 marks)

a. Given the definition of a binary tree , Show the result of inserting {3, 1, 4, 6,
9, 2, 5, 7, } into an initially empty binary search tree. (6 marks)

b. . Show the result of deleting the root and re-draw the Tree (3 marks)

c. provide the inorder, preorder and postorder traversals of the binary search
tree of in figure 3 a (6 marks)

d. Draw a binary tree representing the following arithmetic expressions

“(((5+2)*(2-1))/((2+9)+((7-2)-1))*8)” (4 marks)

B4. (20 marks)

a. Describe ways to handle collision in Hash Table (5 marks)

b. To make learning more interactive, demonstration labs/classes are usually small


sizes in IIUM. In demonstration class of ECE3231, there are only10 students in a
class of 13 students’ capacities. You are require to create an hash table to
indicate where the each students with the following IDs (keys) be
hashed/mapped/sit to in the slot of the class (Hash Table)
𝐼𝐷𝑠 ={18, 41, 22, 5, 44, 59, 33, 31, 73, 13}

5
ECE 3231Algorithms and Programming | Mid-Term Examination | 4 April 2015

Name : Matric No :
Section No: ___________________________

Apply a second hash function to 𝐼𝐷 and probe at a distance Hash2(𝐼𝐷) (double


hashing) using
𝑅 − 𝐼𝐷 𝑚𝑜𝑑 𝑅, 𝑤ℎ𝑒𝑟𝑒 𝑅 = 7
Show details of how each key is converted to array index. (10 marks)

c. What is the average probes of searching for the following ID (keys); {3, 31, 28}
(5 marks)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy