0% found this document useful (0 votes)
22 views37 pages

Cpps Question Bank Sem

The document outlines the curriculum for the first semester of the FY B. Tech (Computer Engineering) program at Pimpri Chinchwad College of Engineering for the academic year 2024-25. It includes various units focused on computer programming and problem-solving, detailing learning objectives, question types, and marks distribution. The document specifies questions related to algorithms, flowcharts, pseudocode, and programming tasks to assess students' understanding and application of these concepts.

Uploaded by

elonmusk2010id
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)
22 views37 pages

Cpps Question Bank Sem

The document outlines the curriculum for the first semester of the FY B. Tech (Computer Engineering) program at Pimpri Chinchwad College of Engineering for the academic year 2024-25. It includes various units focused on computer programming and problem-solving, detailing learning objectives, question types, and marks distribution. The document specifies questions related to algorithms, flowcharts, pseudocode, and programming tasks to assess students' understanding and application of these concepts.

Uploaded by

elonmusk2010id
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/ 37

Pimpri Chinchwad Education Trust’s

Pimpri Chinchwad College of Engineering (PCCoE)

(An Autonomous Institute)

Affiliated to Savitribai Phule Pune University (SPPU)

ISO 21001:2018 Certified by TUV SUD

FY B. Tech. (Computer Engineering)

BCE21ES01: Computer Programming & Problem Solving

First Semester (2024-25)

Department: Computer Engineering A.Y: 2024-25 Sem:1

UNIT-1

BL: Understand –10 Q

BL: Apply – 23 Q

BL: Analyze –08 Q

CO1: Solve various problems using sequential and conditional problem solving approaches

Q No. Question Marks BL CO


No.

Q.1 What is the definition of an algorithm.Provide an example of 5M Understand CO1


a simple algorithm and explain its steps.
Q.2 Explain what an iterative approach is and how it is different 5M Understand CO1
from sequential and conditional approaches. Provide an
example of a problem that can be solved iteratively.

Q.3 Describe the key characteristics of a good algorithm 5M Understand CO1

Q.4 Differentiate between flowcharts and algorithms. 5M Understand CO1

Q.5 Define what a conditional approach is. Provide an example 5M Understand CO1
where a decision is required.

Q.6 Define pseudocode. Write a pseudocode to find the sum and 5M Understand CO1
average of given three numbers.

Q.7 Discuss the advantages of using a flowchart in representing 5M Understand CO1


an algorithm over writing code directly.

Q.8 Draw and briefly explain five symbols commonly used in a 5M Understand CO1
flowchart.

Q.9 Identify the advantages of using flowcharts. 5M Understand CO1

Q.10 Explain what a sequential approach is and provide an 5M Understand CO1


example of a simple problem that can be solved using this
method.

Q.11 Write an algorithm to exchange values of two variables 5M Apply CO1


without temporary variable
Q.12 Write an algorithm to check whether the person is eligible to 5M Apply CO1
vote.

Q.13 Draw a flowchart to find the sum of the first 100 natural 5M Apply CO1
numbers.

Q.14 Draw a flowchart for the process of placing an online order. 6M Apply CO1

Q.15 Draw a flowchart to check if a given number is prime or not. 5M Apply CO1

Q.16 Write an algorithm to exchange values of two variables with 5M Apply CO1
a temporary variable

Q.17 Flowchart for printing odd numbers less than a given number. 7M Apply CO1
It should also calculate their sum and count.

Q.18 Create a simple pseudocode that takes a positive integer as 7M Apply CO1
input and counts the number of digits in that integer.

Q.19 Design an algorithm for a car wash service process. 7M Apply CO1

Q.20 Design a flowchart that models the process of borrowing a 7M Apply CO1
book from a library. Include steps like checking book
availability, verifying user membership, issuing the book, and
setting the return due date.

Q.21 Write pseudo code that will count all the even numbers up to 6M Apply CO1
a user defined stopping point.

Q.22 Construct an algorithm for the college student admission 6M Apply CO1
process.
Q.23 Write pseudo code to print all multiples of 5 between 1 and 6M Apply CO1
100 (including both 1 and 100).

Q.24 Draw a flowchart for calculating the average from 25 exam 7M Apply CO1
scores.

Q.25 Design an algorithm which generates even numbers between 5M Apply CO1

1000 and 2000 and then prints them in the standard output. It
should also print total sum

Q.26 Create a simple pseudocode that takes three numbers as input 5M Apply CO1
and outputs the largest number among them.

Q.27 Write an iterative algorithm to find the maximum number in a 6M Apply CO1
list of integers.

Q.28 Design a flowchart that models the process of registering for 7M Apply CO1
an online exam. Include decision points for checking
available exam slots, verifying payment, and confirming the
registration.

Q.29 Develop an algorithm that determines the eligibility to vote 6M Apply CO1
based on age and citizenship.

Q.30 Write pseudo code that performs the following: Ask a user to 6M Apply CO1
enter a number. If the number is between 0 and 10, write the
word blue. If the number is between 10 and 20, write the
word red. if the number is between 20 and 30, write the word
green. If it is any other number, write that it is not a correct
color option.

Create an algorithm that evaluates the strength of a


Q.31 password based on criteria such as length, inclusion of 5M Apply CO1
numbers, special characters, and uppercase/lowercase
letters.
Q.32 The flowchart below is meant to show the steps 5M Analyze CO1
for making and drinking a glass of blackcurrant squash.

Place the instructions below in the flow chart.


Make sure you put the instructions in the correct order.

Q.33 The flow chart on the right is meant to show the steps 5M Analyze CO1

for stopping working on a computer and shutting it down.

Place the instructions below in the flow chart.


Some of the instructions are not required - you should
only include those which are relevant to the task.
Q.34 SET total = 0 5M Analyze CO1

SET N = 10

FOR i FROM 1 TO N DO

total = total + i
END FOR

PRINT total

What does this pseudocode do, and what will be the output if
N is set to 10?

Q.35 SET number = 8 5M Analyze CO1

IF number MOD 2 = 0 THEN

PRINT "Even"

ELSE

PRINT "Odd"

END IF

Describe the purpose of this pseudocode and what output will


be generated for the given number.

Q.36 SET number = 3 5M Analyze CO1

SET count = 1

WHILE count <= 5 DO

PRINT number * count

count = count + 1

END WHILE

Explain the flow of this pseudocode and what numbers will


be printed.
Q.37 Analyze the following pseudocode snippet and identify any 5M Analyze CO1
potential errors related to operator use:

IF (x = 10) THEN

PRINT "x is ten"

END IF

Explain the mistake and how it could be corrected.

Q.38 x = 5 4M Analyze CO1

y = x += 3

What are the final values of x and y, justify the answer.

Q.39 Design a detailed flowchart for an online shopping process 5M Apply CO1
that allows customers to browse products, add items to their
shopping cart, proceed to checkout, make payments, and
complete their online purchase. The process should include
steps for both registered and guest users.

SET count = 0
Q.40 FOR i = 1 TO 10 5M Analyze CO1
IF i MOD 3 = 0 THEN
count = count + 1
ELSE IF i MOD 4 = 0 THEN
count = count + 2
END IF
END FOR
PRINT count

Describe the purpose of this pseudocode.


What will be the final value of count after the loop
executes?
UNIT-2

BL: Understand –No.of Q- 09

BL: Apply – No.of Q -05

BL: Analyze –No.of Q -03

CO2:Illustrate the conditional and iterative approaches for Problem Solving.

Q No. Question Marks BL CO


No.

Q.1 Define what a factorial is and give examples. 5M Remember CO2

Q.2 Explain how the factorial of a number is calculated. 5M Understand CO2

Q.3 Compute the factorial of 5 using a programming language of 5M Apply CO2


your choice.

Q.4 Design a program that calculates the factorial of a number and 5M Apply CO2
handles invalid inputs.

Q.5 State the formula for computing power. 5M Remember CO2

Q.6 Describe how exponentiation differs from multiplication. 5M Understand CO2

Q.7 Investigate the performance of different algorithms for power 5M Analyze CO2
computation (e.g., naive vs. exponentiation by squaring).

Q.8 Develop a function that computes powers efficiently and includes 5M Apply CO2
error handling for edge cases

Q.9 Discuss the space and time complexity of the Fibonacci generation 5M Understand CO2
algorithms.
Q.10 Write a program that generates Fibonacci numbers up to a 5M Apply CO2
specified limit and outputs them in a formatted way.

Q.11 Define what it means to reverse the digits of a number. 5M Understand CO2

Q.12 Describe the steps involved in reversing a number's digits. 5M Understand CO2

Q.13 Reverse the digits of the number 12345 using a programming 5M Apply CO2
language.

Q.14 Explore different algorithms for reversing digits and their 5M Analyze CO2
efficiencies.

Q.15 Build a user-friendly application that allows users to input a 5M Apply CO2
number and see its digits reversed.

Q.16 State the definition of a square root. 5M Understand CO2

Q.17 Explain the relationship between squares and square roots. 5M Understand CO2

Q.18 Design an algorithm to establish all the primes in the first n 5M Apply CO2
positive integers.

Q.19 SET seed = 1000 5M Analyze CO2

SET a = 1664525

SET c = 1013904223

SET m = 2^32

FOR i = 1 TO 10

SET seed = (a * seed + c) MOD m


PRINT seed

END FOR

Describe the purpose of this pseudocode.

What will be the first four outputs generated based on the given
seed and constants?

Q.20 Describe how to find the smallest divisor of a given integer. 5M Understand CO2

Q.21 Discuss how prime factorization can assist in finding the smallest 5M Evaluate CO2
divisor.

Q.22 Implement a program that finds and displays the smallest divisor 5M Create CO2
of any input integer.

Q.23 Give a stepwise explanation for reversing the digits of a given 5M Understand CO2
number.

Q.24 Write an algorithm to find the GCD of 48 and 18. 5M Apply CO2

Q.25 Define LCM and give examples. 5M Remember CO2

Q.26 Explain the relationship between GCD and LCM. 5M Understand CO2

Q.27 Analyze how the LCM can be computed using the GCD. 5M Analyze CO2

SET i = 2
Q.28 WHILE i * i <= n DO 5M Analyze CO2
IF n MOD i = 0 THEN
PRINT i
SET n = n / i
ELSE
SET i = i + 1
END IF
END WHILE
IF n > 1 THEN
PRINT n
END IF

What is the output for n = 64?

Q.29 Define prime numbers and list the first ten. 5M Remember CO2

Q.30 Explain the characteristics that define a prime number. 5M Understand CO2

Q.31 Write a C program to generate and display prime numbers within a 5M Apply CO2
user-defined range.

Q.32 5M Analyze CO2


SET seed = 144

SET a = 178

SET c = 11032

SET m = 2^16

FOR i = 1 TO 5

SET seed = (a * seed + c) MOD m

PRINT seed

END FOR

Describe the purpose of this pseudocode.

What will be the first four outputs generated based on the given
seed and constants?
Q.33 Define prime factors. 5M Remember CO2

Q.34 Explain the process of finding prime factors. 5M Understand CO2

Q.35 SET seed = 345 5M Analyze CO2

SET a = 210

SET c = 12345

SET m = 2^31

FOR i = 1 TO 5

SET seed = (a * seed + c) MOD m

PRINT seed

END FOR

Describe the purpose of this pseudocode.

What will be the first four outputs generated based on the given
seed and constants?

Q.36 Write a program that computes the LCM of a list of numbers. 5M Apply CO2

Q.37 Describe different methods to compute the n-th Fibonacci number. 5M Understand CO2

Q.38 What will be the output of the given pseudo code? 5M Analyze CO2

Integer a, b, c

a=5

b=6
while(a > 0)

c=a+b

b- -

a- -

Print c

End while

Q.39 SET sum = 0 5M Analyze CO2

FOR i = 1 TO n DO

IF i MOD 2 = 0 THEN

SET sum = sum + i

END IF

END FOR

PRINT sum

What is the output for n=10

Q.40 Generate a list of pseudo-random numbers using a standard library 5M Apply CO2
function.

FOR i = 1 TO sqrt(n) DO
Q.41 IF n MOD i = 0 THEN 5M Analyze CO2
PRINT i
IF i ≠ n / i THEN
PRINT n / i
END IF
END IF
END FOR

What is the output for n = 36 ? Show detailed iterations.


UNIT-3

BL: Understand –14Q

BL: Apply – 23 Q

BL: Analyze –03Q

CO3: Use the array techniques for Problem solving.

Q No. Question Marks BL CO


No.

1 How would you declare and initialize a 3 Understand CO3


one-dimensional array in a programming language

2 How does an algorithm to find the largest element in 4 Understand CO3


an array work?

3 Write a C program to read n numbers into an array 4 Apply CO3


and display them in reverse order.

4 How does an algorithm to find the sum of elements in 4 Understand CO3


an array work?

5 Write an algorithm or program to count the total 4 Apply CO3


number of duplicate elements in an array.

6 Draw a flowchart to print all unique elements in an 4 Apply CO3


array.

7 Design a program to accept details of two matrices. 4 Apply CO3


Add given matrices and print the result
8 Explain how a flowchart can be used to represent the 4 Understand CO3
process of counting the frequency of elements in an
array.

9 How to find the maximum and minimum elements in 4 Understand CO3


an array.

10 Write a program to separate odd and even integers 5 Apply CO3


into two separate arrays, with an example input and
output.

11 Design a program in C to sort elements of an array in 4 Apply CO3


ascending order.

12 Write an algorithm to insert a value into a sorted array 4 Apply CO3


while maintaining the sorted order.

13 Write an algorithm to delete an element at a desired 4 Apply CO3


position from an array.

14 How to store 2D arrays of size 3x3 and print the 2 Understand CO3
matrix.

15 What will be the output of the program if the array 3 Analyze CO3
begins 1200 in memory?

#include<stdio.h>

int main()
{
int arr[]={2, 3, 4, 1, 6};
printf("%u, %u, %u\n", arr, &arr[0], &arr);
return 0;
}
16 How to find the first repeating element in an array of 3 Understand CO3
integers

17 Find the Intersection of the two sorted arrays 4 Understand CO3

18 Write a program in C for the multiplication of two 4 Apply CO3


square matrices.

19 Write a program in C to find the transpose of a given 6 Apply CO3


matrix.

20 Write a program in C to accept two matrices and 6 Apply CO3


check whether they are equal.

21 Write a program in C to find the number occurring 6 Apply CO3


odd number of times in an array.

22 Write a program in C to merge one sorted array into 6 Apply CO3


another sorted array.

23 4 Apply CO3
Write an algorithm to make a histogram of an array

24 Write a C program that takes some integer values 4 Apply CO3


from the user and prints a histogram.

25 6 Apply CO3
C Program to convert Decimal to Binary
27 6 Apply CO3
Write a program in C to find the number of times a
given number appears in an array.

28 3 Understand CO3
Declare and initialize a multidimensional array.

29 2 Understand CO3
Define multi-dimensional array and draw it’s memory
representation

30 3 Apply CO3
Write an algorithm to find Summation of a set of
numbers

31 5 Understand CO3
Explain Union of two sets with example.
Discuss key differences between linear search and
32 binary search. 5 Understand CO3

Write a program to generate Factorial of a given


33 number. 5 Apply CO3

34 5 Understand CO3
Explain the concept of union of two ordered sets to
get a new ordered set with the help of suitable
examples. Take the size of each set at least 6.

35 5 Apply CO3
Write a program to store rainfall in the month of
August and determine the highest rainfall in that
month.

36 5 Analyze CO3
Determine the output of the following code:

#include <stdio.h>

int main() {
int A[] = {1, 1, 0 ,0 ,1, 1};

int B[] = {0, 1, 1, 0, 1, 0};

int C[6] = {0};

for(int i = 0; i < 6; i++){

if(A[i] == 1){

if(B[i] == 1)

C[i] = 1;

else

C[i] = 0;

else

C[i] = 0;

for(int i = 0; i < 6; i++)

printf("%d ", C[i]);

return 0;
}

Explain the working of the code.

37 5 Apply CO3
Design an algorithm to establish all the primes in the
first n positive integers.
Write a step-by-step explanation for removing
38 duplicate elements and producing a resultant array 5 Understand CO3
with unique values for an array of integers.
Describe the process of converting the binary
39 number 377 to binary. Perform the conversion and 5 Apply CO3
write the final result.
Describe the process of converting the binary
40 number 1000001 to octal. Perform the conversion 5 Apply CO3
and write the final result.
UNIT-4

BL: Understand –16Q

BL: Apply – 19Q

BL: Analyze –05Q

CO4: Apply the searching and sorting techniques for problem solving.

Q No. Question Marks BL CO


No.

1 Identify an example where Linear Search might be 4 Understand CO4


preferable over Binary Search.

2 Explain how the order of elements in an array 4 Understand CO4


impacts the functionality of Binary Search.

3 What is the consequence of applying Binary Search 4 Understand CO4


to an unsorted array? How does this affect the search
results?

4 Explain why Binary Search is more efficient than 4 Understand CO4


Linear Search for large datasets.

5 Describe the time complexity of Linear Search and 5 Understand CO4


Binary Search in the best, worst, and average cases.

6 Identify an example where Linear Search might be 4 Understand CO4


preferable over Binary Search.

7 Write a program to find product of two matrices. 5 Apply CO4


8 List the steps involved in performing a binary search 5 Understand CO4
on a sorted array.

9 Use Bubble Sort to sort an array of characters. 4 Apply CO4


Implement the algorithm in C and test it on the array:
['d', 'a', 'c', 'e', 'b'].

10 What is the worst-case time complexity of Linear 4 Understand CO4


Search and Binary Search? How do they compare?

11 Write a Linear Search program in C to search for an 5 Apply CO4


element in an integer array. The program should print
the message “Found” or “Not Found”.

12 Use Linear Search to find the number 42 in the 6 Apply CO4


following array: [15, 22, 39, 42, 55, 60]. Show each
step of the search process.

13 Apply Binary Search to locate the position of the 6 Apply CO4


number 82 in the sorted array: [10, 23, 34, 45, 56, 67,
78, 82, 91]. Show the midpoint calculations and steps
taken.

14 How can an array be reversed without using an 5 Understand CO4


additional array, explain.

15 Evaluate how Binary Search’s time complexity 4 Apply CO4


changes when the size of the input array doubles.
Explain your reasoning.

16 Analyze the space complexity of search algorithms 5 Analyze CO4


(Linear, Binary Search) and discuss which algorithm
would be most efficient in terms of both time and
space for searching in a very large dataset.

17 Evaluate how to modify the Binary Search algorithm 4 Apply CO4


to return the index of the first occurrence of a number
in a sorted array of repeated values.

18 Discuss how the performance of Linear Search and 5 Analyze CO4


Binary Search would change if the data is stored in a
linked list rather than an array.

19 Use Linear Search to find the position of the number 5 Apply CO4
75 in the array: [12, 34, 56, 75, 89, 10, 23, 45]. Walk
through the steps taken during the search.

20 Develop a function using Linear Search to search for 4 Apply CO4


a string in an array of strings. Test the function on the
array: ["apple", "banana", "cherry", "date"].

21 Show the contents of array after every pass of 5 Analyze CO4


Selection Sort algorithm. Explain each iteration.

435190

22 Use Binary Search to find the position of the number 5 Apply CO4
44 in the sorted array: [2, 6, 13, 17, 29, 44, 58, 61].
Show the midpoint calculations and steps involved.

23 What is insertion sort? How many passes are required 5 Understand CO4
for the elements to be sorted ?

24 Briefly differentiate linear search algorithm with 6 Understand CO4


binary search algorithm.
25 Which sorting algorithm is best if the list is already 4 Understand CO4
sorted? Why

26 How does insertion sort algorithm work? 5 Understand CO4

27 Write a C program to sort the array of object prices 5 Apply CO4


from highest to lowest using algorithm of your
choice. State the algorithm used.

28 Explain how Bubble Sort works to sort an array and 4 Understand CO4
how the largest elements "bubble up" to the end of
the list.

Describe the insertion sort algorithm to arrange the


29 array elements in ascending order. 5 Understand CO4

30 What is the time complexity of Selection Sort, and 4 Understand CO4


why does it remain the same regardless of the input
data?

31 Apply Insertion Sort to sort an array of negative and 5 Apply CO4


positive numbers: [3, -1, 0, -8, 10, 4]. Show the
intermediate steps and sorted output.

32 Write a C program to implement Insertion Sort to sort 5 Apply CO4


an array of integers in ascending order. Test the
program with the array: [12, 11, 13, 5, 6]. Print the
array after each insertion step.

Perform a dry run of the insertion Sort algorithm on


33 the following array: 5 Analyze CO4
[31, 15, 19, 42, 20].
Show the array's state after each pass.

34 Use Selection Sort to find the smallest and second 5 Apply CO4
smallest elements in the following array: [34, 22, 10,
19, 17].
35 Write a C program to implement Bubble Sort. Sort 5 Apply CO4
the following array: [64, 34, 25, 12, 22, 11, 90] and
display the sorted array.

36 Use Bubble Sort to sort an array of characters. Test 5 Apply CO4


the program with: ['e', 'b', 'a', 'd', 'c'] and display the
sorted output.

37 Write a C program to implement Bubble Sort and sort 5 Apply CO4


an array of integers. Test it on: [34, 12, 45, 2, 10, 6].
Print the array after each pass.

38 Evaluate the efficiency of Insertion Sort when sorting 5 Analyze CO4


a nearly sorted array versus a completely unsorted
array. Compare the number of shifts and swaps made
by your C program in each case.

39 Compare the time complexity of Selection Sort and 6 Analyze CO4


Insertion Sort for both sorted and unsorted arrays.
Implement both algorithms in C and analyze the
number of comparisons and swaps made on the array:
[20, 12, 10, 15, 2].

40 Write a C program using Selection Sort to find the 5 Apply CO4


k-th smallest element in an array of integers. Use the
array: [23, 12, 31, 17, 46, 5], and find the 3rd
smallest element.
UNIT-5

BL: Understand –22 Q

BL: Apply – 07 Q

BL: Analyze –11 Q

CO5: Apply the appropriate data structure to perform different operations.

Q No. Question Marks BL CO


No.

Q.1 Explain the concept of a stack and its key 5M Understand CO5
characteristics

Q.2 What are the applications of queue? 4M Understand CO5

Q.3 Write a note on dequeue. 4M Understand CO5

Q.4 What is stack? Explain any two applications of stack 5M Understand CO5
with examples.

Q.5 Give the disadvantage of ordinary queue and how it is 4M Understand CO5
solved in circular queue.

Q.6 What is a circular queue? Explain how it differs from 4M Understand CO5
linear queue.

Q.7 Write an algorithm for push operations of stack with 5M Apply CO5
example.
Q.8 Write a pseudocode for below queue operations with 5M Understand CO5
necessary declarations.

1.enQueue() 2.deQueue() 3.isEmpty() 4.isFull() 5.


peek()/front()

Q.9 Show how queues are represented using arrays 5M Understand CO5

Q.10 What are the various Operations performed on the 5M Understand CO5
Stack?

Q.11 Explain the usage of stack in recursive algorithm 5M Understand CO5


implementation

Q.12 How do you test for an empty Queue? 2M Understand CO5

Q.13 Write an algorithm for Push and Pop operations on 5M Apply CO5
Stack

Q.14 Explain the addition and deletion operations 5M Understand CO5


performed on a circular queue with necessary
algorithms

Q.15 Write an algorithm to insert a element onto a queue 5M Apply CO5

Q.16 Distinguish between stack and queue 5M Understand CO5

Q.17 Write function definitions for isFull() and Enqueue() 5M Analyze CO5
functions of Queue, using given prototypes and
declarations for array implementation:

#define size
int Queue[size], front, rear;

int isFull();

void Enqueue(int element);

Q.18 i. 5M Analyze CO5

State the Data Structure (Stack/Queue) required for


conversion of Decimal Number to its Binary
Equivalent.

ii.

____________ is having a LIFO characteristic.

iii.

peek() function decrements the top (true/false).

iv.

enqueue() operation works in constant time. (Yes/No)

v.

Chef taking up orders in a restaurant will be served in


LIFO order. (True/False)

Q.19 Define priority queue with diagram and give the 5M Understand CO5
operations

Q.20 How do you test for an empty stack? 2M Understand CO5

Q.21 What's the output of this code? Assume all stack 5M Analyze CO5
functions definitions are available.

#include <stdio.h>
int stack[12];

int top = -1;

int main() {

int i;

for(i = 0; i < 10; i++){

if(i % 2 == 0)

push( i + 1);

if(i % 3 == 0)

push( i - 1);

while(!isempty())

printf("%d\n", pop());

return 0;

Q.22 Write the status of stack after each operation: 5M Analyze CO5

Stack = 10, 20, 30, 40 where TOP item is 40.


Maximum size of stack is 10

Push 70

Push 100

Pop

Pop

Push 12

Peek
Pop

Push 5

Q.23 Write down the status of Queue after each of the 5M Analyze CO5
successive operation:

Queue = [ 10, 20, 30, 40] where FRONT item is 10


and size of queue is 10

enqueue (70)

dequeue( )

enqueue(80)

enqueue(90)

dequeue( )

dequeue( )

Q.24 Write similarities and differences between Stack and 5M Understand CO5
Queue in a tabular form. Give one real life situation
where each of them can be used.

Q.25 Find output of the given code. Assume all queue 5M Analyze CO5
functions are defined in the code. Show all steps and
explain in brief.

#include <stdio.h>

int queue[10];

int front -1;

int rear = -1;

int main() {

int i;
for(i = 0; i < 4; i++) {

if(i % 2 == 0)

enqueue( i + 1);

if(i % 3 == 0)

enqueue( i);

while(!is_empty())

printf("%d\n", dequeue());

return 0;

Q.26 Write function definitions for Enqueue() and 5M Understand CO5


Dequeue() functions of a Queue. Declare all required
global variables.

Q.27 Write an algorithm to check if a given string is a 5M Apply CO5


palindrome or not. Check the working of your
algorithm for strings “POP” and “CAT”.

Q.28 What's the output of this code? Assume all stack 5M Analyze CO5
functions definitions are available.

#include <stdio.h>

int stack[12];

int top = -1;

int main() {

int i;
for(i = 0; i < 10; i++){

if(i % 2 == 0)

push( i + 1);

if(i % 3 == 0)

push( i - 1);

while(!isempty())

printf("%d\n", pop());

return 0;

Q.29 i. 5M Analyze CO5

State the Data Structure (Stack/Queue) required for


reversing a string.

ii.

If the first element in is the first element out, then the


data structure is a ____________.

iii.

If we want to empty the stack we will have to


repeatedly call _____ function till
________condition.

iv.

dequeue() function operation works in constant time.


(Yes/No)
v.

When the queue is empty front = ______ and rear =


_____.

PUSH(10)
Q.30 PUSH(20) 5M Analyze CO5
POP()
PUSH(30)
PUSH(40)
POP()
PUSH(50)
PRINT STACK

What is the output of the stack?


#include <stdio.h>
Q.31 #define MAX_SIZE 5 5M Analyze CO5

int stack[MAX_SIZE];
int top = -1;

int main() {
for (int i = 0; i < MAX_SIZE; i++) {
stack[++top] = i * 2; // Push elements 0, 2, 4, 6,
8
}

for (int i = 0; i < MAX_SIZE; i++) {


top--; // Pop one element at a time
printf("%d ", stack[top+1]);
}

return 0;
}

What will be the output of the above program?


Illustrate, how will you use stack to reverse a string
Q.32 “SUCCESS”. 5M Apply CO5

List and explain different types of queues with


Q.33 suitable examples. 5M Understand CO5

Q.34 What is queue? Explain any two applications of queue 5M Understand CO5
with examples.

#include <stdio.h>
Q.35 #define MAX_SIZE 5 5M Analyze CO5

int stack[MAX_SIZE];
int top = -1;

int main() {
for (int i = 0; i < MAX_SIZE; i++) {
stack[++top] = i * 2;
}

for (int i = 0; i < MAX_SIZE; i++) {


printf("%d ", stack[i]);
}

return 0;
}

What will be the output of the above program?

Write a pseudocode for below stack operations with


Q.36 necessary declarations. 5M Understand CO5

1.push() 2. pop() 3.isEmpty() 4.


isFull() 5.top()/peek()
True/False: A stack can be implemented using both
Q.37 arrays and linked lists. 5M Analyze CO5

True/False: The peek operation in a stack retrieves


the top element without removing it.

True/False: Stacks are commonly used in recursive


function calls.

True/False: Infix expressions can be directly


evaluated using a stack.

True/False: A stack can have both overflow and


underflow conditions.

#include <stdio.h>
Q.38 #define MAX_SIZE 4 5M Analyze CO5

int stack[MAX_SIZE];
int top = -1;

int main() {
for (int i = 0; i < MAX_SIZE; i++) {
stack[++top] = i + 1; // Pushing values 1, 2, 3,
4
}

for (int i = top; i >= 0; i--) {


printf("%d ", stack[i]);
}

return 0;
}

What will be the output of the above program?

Write a program to reverse the given string.


Q.39 5M Apply CO5
Write a C program to implement a queue using an
Q.40 array. Program should contain functions for inserting 5M Apply CO5
elements into the queue, displaying queue elements,
and checking whether the queue is empty or not.

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