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

CSCL 2102 Lab Data Structures and Algorithms BS AI 3A

This document outlines the midterm exam details for the BS Artificial Intelligence program at Shaheed Zulfikar Ali Bhutto Institute of Science and Technology University. It includes important instructions for students, a breakdown of exam questions related to data structures and algorithms, and the corresponding marks for each question. The exam is designed to assess students' understanding and implementation of various algorithms and data structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

CSCL 2102 Lab Data Structures and Algorithms BS AI 3A

This document outlines the midterm exam details for the BS Artificial Intelligence program at Shaheed Zulfikar Ali Bhutto Institute of Science and Technology University. It includes important instructions for students, a breakdown of exam questions related to data structures and algorithms, and the corresponding marks for each question. The exam is designed to assess students' understanding and implementation of various algorithms and data structures.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SHAHEED ZULFIKAR ALI BHUTTO INSTITUTE OF

SCIENCE AND TECHNOLOGY UNIVERSITY

midterm exam fall 2024

Program: BS Artificial Intelligence Class: (III A)


Course Name: Lab Data Structures and Algorithms Duration: 1.5 hrs
Instructor’s Name: Mrs. Soha khan Total Marks: 20

Course Code: CSCL 2102 Date: _____________

IMPORTANT instructions:
 Students are strictly advised not to bring cell phones/smart watch and/or any
kind of electronic devices in the examination hall except for a simple
calculator (if allowed). If they bring any such devices in the examination hall,
they should make sure that the cell phones/smart watch and/or any other
electronic device is properly switched off. Otherwise, a penalty including “F”
grade could be awarded.
 Read all the questions carefully first and then ask for clarifications.
 Question paper related queries will not be entertained after 30 minutes for midterm
exams and 60 minutes for final exam after the start of the exam.
 Do not write anything on the question paper unless specifically asked to do so by your
course instructor.
 Marks of each question are mentioned at the end of each question.

BT
CLO Description Domain
Level*
Implement various data Structures and their algorithms and Cognitive
1 2,3
apply them in implementing simple applications. domain
Implement hash tables, including collision avoidance and Cognitive
2 2
resolution. domain
*BT=Bloom’s Taxonomy, C=Cognitive domain, P=Psychomotor domain, A=Affective
domain
SHAHEED ZULFIKAR ALI BHUTTO INSTITUTE OF
SCIENCE AND TECHNOLOGY UNIVERSITY

Section- A

Q1. (Clo_2,3) (GA_2) [3


marks]
Create an array of 10 floating-point numbers. Take the input from the user, calculate, and print
both the sum and the average of the numbers.

Q2. (Clo_2,3) (GA_2) [7


marks]
Write programs for the following two different algorithms to check if a given number is even or
odd:
First Algorithm:
if n % 2 == 0
n is even
else
n is odd

Second Algorithm:
if the last digit of n is 0, 2, 4, 6, or 8
n is even
else
n is odd

Calculate the number of steps taken by these programs for the following values and determine
which algorithm is faster. Assume the computer takes 1 millisecond for each step.

i. n = 7
ii. n = 42
iii. n = 1003
iv. n = 987654321

Q3. (Clo_2,3) (GA_2) [4


marks]

Implement the bubble and selectionSort function to sort an array of integers in ascending order.
Write a helper function printArray to display the contents of the array before and after sorting. Test
your implementation with the following array: {54, 35, 12, 34, 22}.

Q4. (Clo_2,3) (GA_2) [6


marks]

a. Take 5 values from the user and insert them into an array.
b. Display the values in the array. [6 marks]
c. Ask the user to enter a number to search for.
d. Ask the user to choose either Linear Search or Binary Search.
e. If Binary Search is chosen, sort the array automatically before searching.
SHAHEED ZULFIKAR ALI BHUTTO INSTITUTE OF
SCIENCE AND TECHNOLOGY UNIVERSITY

f. Perform the search based on the user's choice and display whether the number was found and at
which index, or display a message if the number is not found.

Your output should include:

 The list of entered values


 The search method chosen
 A message stating whether the number was found, and if so, the index of the value

You might also like