(V SEM) THEORY EXAMINATION 2022-23 PROGRAMMING, DATA STRUCTURES AND ALGORITHMS USING PYTHON

B.Tech Data Structure 0 downloads
₹29.00

SECTION A (2 × 10 = 20 Marks)

Attempt all questions in brief
 

(a) Characteristics of Python
Python is a high-level, interpreted programming language that is easy to learn and use. It supports object-oriented as well as procedural programming. Python is platform independent, which means the same code can run on different operating systems without modification. It uses dynamic typing, so variables do not need to be declared explicitly. Python has a large standard library that helps in rapid application development.
 

(b) Syntax of range() method
The range() function in Python is used to generate a sequence of numbers. Its syntax is range(start, stop, step). The start value indicates where the sequence begins, the stop value specifies where it ends (excluding that value), and the step value defines the difference between consecutive numbers. It is commonly used in loops for iteration.
 

(c) Tuple data structure
A tuple is an ordered collection of elements in Python that is immutable in nature. Once a tuple is created, its elements cannot be modified. Tuples are written using parentheses and are faster than lists. For example, a tuple can be created as t = (10, 20, 30). Tuples are mainly used when data should not be changed accidentally.
 

(d) Big O notation
Big O notation is used to describe the time complexity of an algorithm. It tells how the execution time of an algorithm increases with the size of input data. For example, a linear search algorithm has a time complexity of O(n), while a binary search algorithm has a time complexity of O(log n). Big O helps in comparing algorithm efficiency.
 

(e) Value of Y
Given X = “I love India” and Y = X[:9:2], Python slicing starts from index 0 up to index 8 and skips every second character. The resulting value of Y is “Ilv ni”.
 

(f) Variable length argument
Variable length arguments allow a function to accept any number of arguments. This is useful when the number of inputs is not fixed. In Python, this is achieved using *args. Inside the function, args behaves like a tuple and can be processed using loops or functions.
 

(g) Comparison between list and tuple
A list is mutable, which means its elements can be changed after creation, while a tuple is immutable. Lists use square brackets, whereas tuples use parentheses. Lists require more memory compared to tuples. Tuples are generally used for fixed data, while lists are used when data needs to be updated frequently.
 

(h) Importance of memoization
Memoization is a technique used to store the results of expensive function calls and reuse them when the same inputs occur again. It improves program efficiency, especially in recursive algorithms like Fibonacci or dynamic programming problems, by avoiding repeated calculations.
 

(i) Hashing and collision techniques
Hashing is a technique used to map keys to values using a hash function. A collision occurs when two keys generate the same hash value. To resolve collisions, techniques such as chaining, linear probing, quadratic probing, and double hashing are used.
 

(j) Abstract Data Type (ADT)
An abstract data type defines a data structure by specifying the operations that can be performed on it without specifying the implementation. Examples of ADTs include stack, queue, and list. ADTs help in separating data representation from data usage.
 

SECTION B (10 × 3 = 30 Marks)
 

(a) List comprehension and matrix multiplication
List comprehension is a concise way to create lists in Python using a single line of code. It improves code readability and efficiency. In matrix multiplication, list comprehension can be used to compute the product of two matrices by multiplying rows of the first matrix with columns of the second matrix and summing the results. This approach avoids nested loops and produces compact code.
 

(b) filter(), map(), and reduce() functions
The filter() function is used to select elements from a sequence based on a condition. The map() function applies a given function to each element of a sequence and returns a new sequence. The reduce() function, available in the functools module, reduces a sequence to a single value by repeatedly applying a function. These functions support functional programming in Python.
 

(c) Exception handling in Python
Exception handling is used to manage runtime errors and prevent program termination. Python uses try, except, and finally blocks to handle exceptions. For example, dividing a number by zero raises a ZeroDivisionError. Using exception handling ensures that the program continues to run smoothly even when errors occur.
 

(e) Binary search algorithm
Binary search is an efficient searching technique used on sorted lists. It works by repeatedly dividing the search interval into two halves. If the target value is less than the middle element, the search continues in the left half; otherwise, it continues in the right half. The time complexity of binary search is O(log n), which makes it faster than linear search.
 

SECTION C
 

Q3 (a) Queue data structure

A queue is a linear data structure that follows the First In First Out (FIFO) principle. The element that is inserted first is removed first. Basic operations performed on a queue are enqueue, dequeue, and peek. In Python, a queue can be implemented using a list where elements are added at the end and removed from the front.
 

Q4 (b) Loop control statements

Loop control statements are used to control the execution of loops. The break statement terminates the loop immediately. The continue statement skips the current iteration and moves to the next one. The pass statement acts as a placeholder and does nothing but avoids syntax errors when a statement is required.
 

Q5 (a) Merge sort

Merge sort is a divide and conquer algorithm that divides the list into smaller sublists until each sublist contains one element. Then, these sublists are merged in a sorted manner. Merge sort has a time complexity of O(n log n) and is suitable for sorting large datasets efficiently.
 

Q6 (a) Longest Common Subsequence (LCS)

The longest common subsequence problem involves finding the longest sequence that appears in the same order in two sequences. It is solved using dynamic programming. For X = (B, A, C, D, B) and Y = (B, D, C, B), the longest common subsequence is BCB.
 

Q7 (a) Binary Search Tree (BST)

A binary search tree is a hierarchical data structure where the left subtree contains elements smaller than the root and the right subtree contains elements larger than the root. Insertion is done by comparing values and placing them accordingly. Deletion of nodes such as 21 and 25 involves finding a suitable replacement, usually the inorder successor, to maintain the BST property.

File Size
111.74 KB
Uploader
SuGanta International

Featured educators

Meet our verified teachers

Browse profiles with clear experience, subjects, and availability—then open the full profile in SuGanta.

KISHAN KUMAR DUBEY

KISHAN KUMAR DUBEY

Sant Ravidas Nagar Bhadohi, Uttar Pradesh

This is Kishan Kumar Dubey. I have done my schooling from CBSE, graduation from CSJMU, post graduation from ASU and appear in B.Ed. from MGKVP on aided seat. I have 2 years experience in academic class (Future Shapers C...

Both Online & Offline · Member since 2026

A-Level Chemistry A-Level Mathematics

Subjects

2

Experience

5 Years

Hourly

₹201-300

Swethavyas bakka

Swethavyas bakka

Hyderabad, Telangana

I have 10+ years of experience in teaching maths physics and chemistry for 10th 11th 12th and intermediate students all my students till today are 90% grade. Even an average student got 90%

Both Online & Offline · Member since 2026

A-Level Mathematics Advanced Chemistry (Secondary) +3

Subjects

5

Experience

10 Years

Hourly

₹501-600

Vijaya Lakshmi

Vijaya Lakshmi

Hyderabad, Telangana

I am an experienced teacher ,worked with many reputed institutions Mount Carmel Convent , Chandrapur Maharashtra India, St Paul’s H.S Hyderabad, Fiitjee school Narayanaguda. I have handled students of different age gr...

Online Only · Member since 2026

A-Level Biology A-Level Physics +8

Subjects

10

Experience

30+ Years

Hourly

₹501-600

Shifna sherin F

Shifna sherin F

Gudalur, Tamilnadu

Hi, I’m Shifna Sherin! I believe that every student has the potential to excel in Math with the right guidance. I offer dedicated tutoring for 10th-grade students, covering everything from foundational basics to advanced...

Both Online & Offline · Member since 2026

Advanced Mathematics (Middle School) Advanced Mathematics (Secondary) +6

Subjects

8

Experience

5 Years

Hourly

₹401-500

Divyank Gautam

Divyank Gautam

Pune, Maharashtra

An IIT graduate having 8 years of experience teaching Maths. Passionate to understand student problems and accordingly innovate teaching methodology.

Private tutor · Member since 2026

Subjects

Experience

Status

Explore Tutors In Your Location

Discover expert tutors in popular areas across India

SEO Training Near Noida Sector 93 – Learn Search Engine Op... Sector 93, Greater Noida
Data Analytics Training Near Noida Sector 94 – Learn Data... Greater Noida
SEO Training Near Noida Sector 95 – Learn Search Engine Op... Greater Noida
Digital Marketing Classes Near Noida Sector 96 – Learn Mod... Greater Noida
Graphic Designing Classes Near Noida Sector 97 – Learn Cre... Sector 97, Greater Noida
Digital Marketing Classes Near Noida Sector 98 – Learn Mod... Expressway, Sector 98, Noida, Greater Noid...
Graphic Designing Classes Near Noida Sector 99 – Learn Cre... Greater Noida
App Development Classes Near Noida Sector 100 – Learn Mobi... Sector 100, Greater Noida
Web Development Classes Near Noida Sector 101 – Learn Codi... Greater Noida
App Development Classes Near Noida Sector 102 – Complete G... Greater Noida
Web Development Classes Near Noida Sector 103 – Complete G... Greater Noida
TOEFL Coaching Near Noida Sector 104 – Complete Preparatio... Sector 104, Greater Noida
IELTS Coaching Near Noida Sector 105 – Complete Guide for... Greater Noida
TOEFL Coaching Near Noida Sector 106 – Complete Guide for... Greater Noida
IELTS Coaching Near Noida Sector 107 – Expert Training for... Greater Noida
Public Speaking Training Near Sector 108 Noida – Build Con... Greater Noida
Public Speaking Training Near Sector 109 Noida – Improve C... Greater Noida
🇯🇵 Japanese Language Classes Near Sector 110 Noida – Learn... Sector 110, Greater Noida
🇪🇸 Spanish Language Classes Near Sector 111 Noida – Learn... Greater Noida
🇫🇷 French Language Classes Near Sector 112 Noida – Learn F... Greater Noida
⭐ Premium Institute Network

Discover Elite Educational Institutes

Connect with top-tier educational institutions offering world-class learning experiences, expert faculty, and innovative teaching methodologies

SHASTRI'S PHYSICS CLASSES, NAGPUR

Type

Coaching Center

SHASTRI'S PHYSICS CLASSES, NAGPUR

Nagpur, Maharashtra

Best Physics Classes in Nagpur | Shastri's Physics Classes offers expert coaching for CBSE. MS-BOARD, NEET, JEE, MHT-CET, 11th & 12th Physics. Clear concepts, regular tests & personal doubt solving. J...

Private · Est. 2021-Present

Students

51-100

Teachers

1-10

Branches

1

Réussi Academy of languages

Type

Coaching Center

Réussi Academy of languages

Geeta Bhawan Square, Indore, Madhya pradesh

Excellence in Language. Leadership in Results. With over 18 years of distinguished experience, Réussi Academy of Language stands as a trusted name in foreign language and communication training. Foun...

Private · Est. 2021-Present

Students

1-50

Teachers

1-10

Branches

1

IGS Institute

Type

Coaching Center

IGS Institute

Sector 22, Noida, Uttar Pradesh

IGS Institute provide classes for SSC, Bank, Railway, Police, NDA, Airforce Group X and Group Y, Teaching exams. IGS - Institute for Government Services providing classes since 2018 to the students.

Private · Est. 2011-2020

Students

51-100

Teachers

1-10

Branches

1

Krishna home tutor

Type

School

Krishna home tutor

New Delhi, New Delhi

Hi everyone, Krishna home tutor. Providing tutors for all subjects and classes since 2001.

Private · Est. 2001-2010

Students

201-500

Teachers

76-100

Branches

1

Edustunt Tuition Centre

Type

Coaching Center

Edustunt Tuition Centre

Hoshiarpur, Punjab

We provide online& offline tuition classes,doubt clearance sessions & exam preparation services for students from school level to university level.

Private · Est. 2021-Present

Students

1-50

Teachers

1-10

Branches

1