(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
⭐ Elite Educators Network

Meet Our Exceptional Teachers

Discover passionate educators who inspire, motivate, and transform learning experiences with their expertise and dedication

KISHAN KUMAR DUBEY

KISHAN KUMAR DUBEY

Sant Ravidas Nagar Bhadohi, Uttar Pradesh , Babusarai Market , 221314
5 Years
Years
₹10000+
Monthly
₹201-300
Per Hour

This is Kishan Kumar Dubey. I have done my schooling from CBSE, graduation from CSJMU, post graduati...

Swethavyas bakka

Swethavyas bakka

Hyderabad, Telangana , 500044
10 Years
Years
₹10000+
Monthly
₹501-600
Per Hour

I have 10+ years of experience in teaching maths physics and chemistry for 10th 11th 12th and interm...

Vijaya Lakshmi

Vijaya Lakshmi

Hyderabad, Telangana , New Nallakunta , 500044
30+ Years
Years
₹9001-10000
Monthly
₹501-600
Per Hour

I am an experienced teacher ,worked with many reputed institutions Mount Carmel Convent , Chandrapu...

Shifna sherin F

Shifna sherin F

Gudalur, Tamilnadu , Gudalur , 643212
5 Years
Years
₹6001-7000
Monthly
₹401-500
Per Hour

Hi, I’m Shifna Sherin! I believe that every student has the potential to excel in Math with the righ...

Divyank Gautam

Divyank Gautam

Pune, Maharashtra , Kothrud , 411052
3 Years
Years
Not Specified
Monthly
Not Specified
Per Hour

An IIT graduate having 8 years of experience teaching Maths. Passionate to understand student proble...

Explore Tutors In Your Location

Discover expert tutors in popular areas across India

SEO Training Near Sector 63 Gurugram – Master Search Engine Optimization & Build a High-Growth Career Sector 63, Gurugram
Spoken English Classes Near By Jangpura Improve Fluency, Build Confidence & Grow Career Opportunities in 2026 Jangpura, Delhi
Stenography Classes Near Sector 93 Gurugram – Build Speed, Accuracy & Secure Government Career Opportunities Sector 93, Gurugram
Spoken English Classes Near By Najafgarh Improve Fluency, Build Confidence & Open New Career Opportunities in 2026 Najafgarh, Delhi
Guitar Classes Near By Lajpat Nagar Learn Guitar with Expert Trainers & Turn Your Passion into a Powerful Skill Lajpat Nagar, Delhi
Spoken English Classes Near By New Friends Colony Improve Fluency, Boost Confidence & Unlock Career Growth in 2026 New Friends Colony, Delhi
Fitness Training Near By Najafgarh Professional Workout Programs for Strength, Weight Loss & Overall Wellness Najafgarh, Delhi
Yoga Classes Near Sector 138 Greater Noida – Improve Health, Mind & Lifestyle Through Professional Yoga Training Noida
SEO Training Near Noida Sector 95 – Learn Search Engine Optimization and Build a Digital Career Noida
Personality Development Classes Near Sector 56 Gurugram – Build Confidence, Communication & Professional Success Sector 56, Gurugram
Graphic Designing Classes Near Noida Sector 97 – Learn Creative Design Skills and Build Your Career Sector 97, Noida
Violin Classes Near DLF Phase 5 – Learn, Grow & Perform with Confidence DLF Phase V, Gurugram
History Classes Near Sector 91 Gurugram – Build Strong Understanding of the Past for a Better Future Gurugram
Drawing & Sketching Classes Near By Uttam Nagar – Explore Your Creative Potential Uttam Nagar, Delhi
Tailoring & Stitching Classes Near By Dwarka Mor – Learn Professional Sewing Skills Dwarka Mor, Delhi
Spoken English Classes Near By Malviya Nagar Build Confidence, Improve Fluency & Unlock Career Opportunities in 2026 Malviya Nagar, Delhi
Spoken English Classes Near Sector 117 Noida – Improve Fluency, Confidence and Communication Skills Noida
Meditation Coaching Near By Nangloi – Find Inner Peace & Mental Clarity Nangloi, Delhi
Yoga Classes Near By Defence Colony Experience Holistic Fitness, Mental Peace & Lifestyle Transformation in 2026 Defence Colony, Delhi
Voice-over Training Classes Near By Saket – Build a Powerful & Professional Voice Saket, Delhi
⭐ Premium Institute Network

Discover Elite Educational Institutes

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

Réussi Academy of languages

sugandha mishra

Réussi Academy of languages
Madhya pradesh, Indore, G...

Details

Coaching Center
Private
Est. 2021-Present

Sugandha Mishra is the Founder Director of Réussi Academy of Languages, a premie...

IGS Institute

Pranav Shivhare

IGS Institute
Uttar Pradesh, Noida, Sec...

Details

Coaching Center
Private
Est. 2011-2020

Institute For Government Services

Krishna home tutor

Krishna Home tutor

Krishna home tutor
New Delhi, New Delhi, 110...

Details

School
Private
Est. 2001-2010

Krishna home tutor provide tutors for all subjects & classes since 2001

Edustunt Tuition Centre

Lakhwinder Singh

Edustunt Tuition Centre
Punjab, Hoshiarpur, 14453...

Details

Coaching Center
Private
Est. 2021-Present
Great success tuition & tutor

Ginni Sahdev

Great success tuition & tutor
Delhi, Delhi, Raja park,...

Details

Coaching Center
Private
Est. 2011-2020