SlideShare a Scribd company logo
Aastha Shah_Ganpat University
August_Infotech Technical Round Questions.
Que1. Write a program or algorithm to Reverse a String using the Stack method. [5
marks]
input: Hello World!
output: !dlroW olleH
Code:
def createStack():
stack=[]
return stack
def size(stack):
return len(stack)
def empty(stack):
if size(stack) == 0:
return true
def push(stack, item):
stack.append(item)
def pop(stack):
if empty(stack):
return
Aastha Shah_Ganpat University
return stack.pop()
def reverse(string):
n = len(string)
stack = createStack()
for i in range(0,n,1):
push(stack, string[i])
string = ""
for i in range(0,n,1):
string += pop(stack)
return string
string = "Hello World"
string = reverse(string)
print("Reversed string is" + string)
Aastha Shah_Ganpat University
Aastha Shah_Ganpat University
Que 2. Write a program or algorithm to sort list using the merge sort method. [10
marks]
input: 6 5 4 7 1
output after merge sort: 1 4 5 6 7
Code:
def mergeSort(arr):
if len(arr) > 1:
mid = len(arr) // 2
L = arr[:mid]
R = arr[mid:]
mergeSort(L)
mergeSort(R)
i=j=k=0
while i<len(L) and j<len(R):
if L[i] <= R[j]:
arr[k] = L[i]
i+=1
else:
arr[k] = arr[R]
j+=1
k+=1
Aastha Shah_Ganpat University
while i<len(L):
arr[k] = L[i]
i+=1
k+=1
while i<len(R):
arr[k] = R[j]
j+=1
k+=1
def printList(arr):
for i in range(len(arr)):
print(arr[i], end=" ")
print()
if _name_ == '__main__':
arr = [6,5,4,7,1]
print("Given arry is", end="n")
printList(arr)
mergeSort(arr)
print("Sorted array is:", end="n")
printList(arr)
Aastha Shah_Ganpat University
Que 3. Write a program or algorithm to Delete N nodes after M nodes of a linked
list. [10 marks]
Example-1
input: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 10
N=2, M=3
output: 1 → 2 → 3 → 6 → 7 → 8
Example-2
input: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 10 → 11
N=3, M=3
output: 1 → 2 → 3 → 7 → 8 → 9
Code:
class Node:
def _init_(self,data):
self.data = data
self.next = None
class List:
def _init_(self):
self.head = None
def push(self,new_data):
new_node = Node(new_data)
new_node.next = self.head
Aastha Shah_Ganpat University
self.head = new_node
def printList(self):
temp = self.head
while(temp):
print(temp.data, end=" ")
temp = temp.next
def skipMdeleteN(self,M,N):
curr = self.head
while(curr):
for count in range(1,M):
if curr is None:
return
curr = curr.next
if curr is None:
return
t = curr.next
for count in range(1,N+1):
if t is None:
Aastha Shah_Ganpat University
break
t = t.next
curr.next = t
curr = t
llist = List()
M = 2
N = 3
llist.push(10)
llist.push(9)
llist.push(8)
llist.push(7)
llist.push(6)
llist.push(5)
llist.push(4)
llist.push(3)
llist.push(2)
llist.push(1)
print("M = %d, N = %dnGiven linked list is:" %(M,N))
llist.printList()
print()
Aastha Shah_Ganpat University
llist.skipMdeleteN(M,N)
print("nLinked list after deletion is")
list.printList()
Aastha Shah_Ganpat University
Que 4. Write a program or algorithm for Two Elements whose sum is closest to
zero. [5 marks]
Example
You are given an array [-23, 12, -35, 45, 20, 36] then the two elements would be -35 &
36 as their pair sum is 1 which is closest to 0
Code:
def minSum(arr,arr_size):
inv_count = 0
if arr_size < 2:
print("Invalid Input")
return
min_l = 0
min_r = 1
min_sum = arr[0] + arr[1]
for l in range (0,arr_size,-1):
for r in range(l + 1, arr_size):
sum = arr[l] + arr[r]
if abs(min_sum) > abs(sum):
min_sum = sum
min_l = l
min_r = r
Aastha Shah_Ganpat University
print("Two elements whose sum is closest to 0 are: " + arr[min_l], + "and" +
arr[min_r])
arr = [-23, 12, -35, 45, 20, 36]
minSum(arr,6);
Aastha Shah_Ganpat University
Que 5. From the following table, write a SQL query to find customers who are
either from the city 'New York' or who do not have a grade greater than 100.
Return customer_id, cust_name, city, grade, and salesman_id.
Query:
SELECT * FROM customer_id WHERE NOT(city = 'New York' OR grade>100);
Aastha Shah_Ganpat University
Que 6. From the above customer table, write a SQL query to determine the
number of customers who received at least one grade for their activity.
Query:
SELECT COUNT (ALL grade) FROM customer_id

More Related Content

Similar to Aastha Shah.docx

Lecture2
Lecture2Lecture2
Lecture2
FALLEE31188
 
Data structure
Data  structureData  structure
Data structure
Arvind Kumar
 
Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical File
KushagraChadha1
 
Functional programming with_scala
Functional programming with_scalaFunctional programming with_scala
Functional programming with_scala
Raymond Tay
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
arnold 7490
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
Nitesh Dubey
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
Software Guru
 
Monadologie
MonadologieMonadologie
Monadologie
league
 
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181
Mahmoud Samir Fayed
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
Prof. Dr. K. Adisesha
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
SajalFayyaz
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
Nithin Kumar,VVCE, Mysuru
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
intelliyole
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
PrudhviVuda
 
Python Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation LearningPython Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation Learning
Naseer-ul-Hassan Rehman
 
Ning_Mei.ASSIGN03
Ning_Mei.ASSIGN03Ning_Mei.ASSIGN03
Ning_Mei.ASSIGN03
宁 梅
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
tameemyousaf
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
Asst.prof M.Gokilavani
 
Scala
ScalaScala
07012023.pptx
07012023.pptx07012023.pptx
07012023.pptx
NareshBopparathi1
 

Similar to Aastha Shah.docx (20)

Lecture2
Lecture2Lecture2
Lecture2
 
Data structure
Data  structureData  structure
Data structure
 
Algorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical FileAlgorithm Design and Analysis - Practical File
Algorithm Design and Analysis - Practical File
 
Functional programming with_scala
Functional programming with_scalaFunctional programming with_scala
Functional programming with_scala
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
Ejercicios de estilo en la programación
Ejercicios de estilo en la programaciónEjercicios de estilo en la programación
Ejercicios de estilo en la programación
 
Monadologie
MonadologieMonadologie
Monadologie
 
The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181The Ring programming language version 1.5.2 book - Part 35 of 181
The Ring programming language version 1.5.2 book - Part 35 of 181
 
Xi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programsXi CBSE Computer Science lab programs
Xi CBSE Computer Science lab programs
 
Data structure 8.pptx
Data structure 8.pptxData structure 8.pptx
Data structure 8.pptx
 
VTU Data Structures Lab Manual
VTU Data Structures Lab ManualVTU Data Structures Lab Manual
VTU Data Structures Lab Manual
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Python Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation LearningPython Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation Learning
 
Ning_Mei.ASSIGN03
Ning_Mei.ASSIGN03Ning_Mei.ASSIGN03
Ning_Mei.ASSIGN03
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
 
GE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_NotesGE3151_PSPP_UNIT_4_Notes
GE3151_PSPP_UNIT_4_Notes
 
Scala
ScalaScala
Scala
 
07012023.pptx
07012023.pptx07012023.pptx
07012023.pptx
 

Recently uploaded

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 

Recently uploaded (20)

A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 

Aastha Shah.docx

  • 1. Aastha Shah_Ganpat University August_Infotech Technical Round Questions. Que1. Write a program or algorithm to Reverse a String using the Stack method. [5 marks] input: Hello World! output: !dlroW olleH Code: def createStack(): stack=[] return stack def size(stack): return len(stack) def empty(stack): if size(stack) == 0: return true def push(stack, item): stack.append(item) def pop(stack): if empty(stack): return
  • 2. Aastha Shah_Ganpat University return stack.pop() def reverse(string): n = len(string) stack = createStack() for i in range(0,n,1): push(stack, string[i]) string = "" for i in range(0,n,1): string += pop(stack) return string string = "Hello World" string = reverse(string) print("Reversed string is" + string)
  • 4. Aastha Shah_Ganpat University Que 2. Write a program or algorithm to sort list using the merge sort method. [10 marks] input: 6 5 4 7 1 output after merge sort: 1 4 5 6 7 Code: def mergeSort(arr): if len(arr) > 1: mid = len(arr) // 2 L = arr[:mid] R = arr[mid:] mergeSort(L) mergeSort(R) i=j=k=0 while i<len(L) and j<len(R): if L[i] <= R[j]: arr[k] = L[i] i+=1 else: arr[k] = arr[R] j+=1 k+=1
  • 5. Aastha Shah_Ganpat University while i<len(L): arr[k] = L[i] i+=1 k+=1 while i<len(R): arr[k] = R[j] j+=1 k+=1 def printList(arr): for i in range(len(arr)): print(arr[i], end=" ") print() if _name_ == '__main__': arr = [6,5,4,7,1] print("Given arry is", end="n") printList(arr) mergeSort(arr) print("Sorted array is:", end="n") printList(arr)
  • 6. Aastha Shah_Ganpat University Que 3. Write a program or algorithm to Delete N nodes after M nodes of a linked list. [10 marks] Example-1 input: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 10 N=2, M=3 output: 1 → 2 → 3 → 6 → 7 → 8 Example-2 input: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 10 → 11 N=3, M=3 output: 1 → 2 → 3 → 7 → 8 → 9 Code: class Node: def _init_(self,data): self.data = data self.next = None class List: def _init_(self): self.head = None def push(self,new_data): new_node = Node(new_data) new_node.next = self.head
  • 7. Aastha Shah_Ganpat University self.head = new_node def printList(self): temp = self.head while(temp): print(temp.data, end=" ") temp = temp.next def skipMdeleteN(self,M,N): curr = self.head while(curr): for count in range(1,M): if curr is None: return curr = curr.next if curr is None: return t = curr.next for count in range(1,N+1): if t is None:
  • 8. Aastha Shah_Ganpat University break t = t.next curr.next = t curr = t llist = List() M = 2 N = 3 llist.push(10) llist.push(9) llist.push(8) llist.push(7) llist.push(6) llist.push(5) llist.push(4) llist.push(3) llist.push(2) llist.push(1) print("M = %d, N = %dnGiven linked list is:" %(M,N)) llist.printList() print()
  • 10. Aastha Shah_Ganpat University Que 4. Write a program or algorithm for Two Elements whose sum is closest to zero. [5 marks] Example You are given an array [-23, 12, -35, 45, 20, 36] then the two elements would be -35 & 36 as their pair sum is 1 which is closest to 0 Code: def minSum(arr,arr_size): inv_count = 0 if arr_size < 2: print("Invalid Input") return min_l = 0 min_r = 1 min_sum = arr[0] + arr[1] for l in range (0,arr_size,-1): for r in range(l + 1, arr_size): sum = arr[l] + arr[r] if abs(min_sum) > abs(sum): min_sum = sum min_l = l min_r = r
  • 11. Aastha Shah_Ganpat University print("Two elements whose sum is closest to 0 are: " + arr[min_l], + "and" + arr[min_r]) arr = [-23, 12, -35, 45, 20, 36] minSum(arr,6);
  • 12. Aastha Shah_Ganpat University Que 5. From the following table, write a SQL query to find customers who are either from the city 'New York' or who do not have a grade greater than 100. Return customer_id, cust_name, city, grade, and salesman_id. Query: SELECT * FROM customer_id WHERE NOT(city = 'New York' OR grade>100);
  • 13. Aastha Shah_Ganpat University Que 6. From the above customer table, write a SQL query to determine the number of customers who received at least one grade for their activity. Query: SELECT COUNT (ALL grade) FROM customer_id