Coding | Mcqs | Multiple choice questions | Informative | Computer Science | Engineering | Aptitude | Quants | Verbal

INFEED

SBT | DAILY TEST

 

 check indentation for programming

 

 TECHNICAL MCQ 


1. a

2. a

3.  a

4.  a

5.  b

6.  d

7.  a

8.  a

9.  b

10. d

11. c

12. a

13. a

14. b

15. d

16. c

17.  b

18.  a

19. b

20.  b





28. b

29. d

30.  c


**************************************************************************

PROGRAMMING

1.

Problem statement
Vishal is a competitive coder and he loves problems on sorting and searching. He is bored right now
and decides to solve a sorting problem with a modification. He decides to sort the elements at the
even indices of an array in ascending order and the elements at the odd indices in descending order.
Vishal goes outside his room after coding the solution, but his laptop crashes and he is unable to show
it to his teacher. Can you help Vishal by coding the solution to the problem?
Input Format
First line contains size of the array. Next line contains elements of the array.
Constraints
1<=size of array<=1000
0<=arrayi<=10000
Output Format
Sorted elements of the array

 SOLUTION :

PYTHON CODE :

b=int(input())

a=list(map(int,input().split()))

a1=[]

a2=[]

for i in range(b):

  if(i%2==0):

    a1.append(a[i])

  else:

    a2.append(a[i])

a1=sorted(a1)

a2=sorted(a2,reverse=True)

l1=0

l2=0

for i in range(b):

  if(i%2==0):

    print(a1[l1],end=" ")

    l1+=1

  else:

    print(a2[l2],end=" ")

    l2+=1

 


2.

Problem statement
Consider a list with all strings. Sort the list by calculating the length of the strings in the given list in
ascending order.
Input Format
Input a list of strings
Output Format
print the list based on the string lengths

 

 SOLUTION :

PYTHON CODE :

 def Sorting(lst):

    lst.sort(key=len)
     return lst

 Driver code
lst = list(input().split())
print(*Sorting(lst))

 

3.

Problem statement
Given an array of n distinct elements. Print the minimum number of swaps required to sort the array in
strictly increasing order.
Input Format
First line of input contains intger n-the size of array. Next line of input contains n integers the n
elements of array.
Constraints
1 ≤ n ≤ 10^5
1 ≤ numsi ≤ 10^6
Output Format
Print the minimum number of swaps required to sort the array in strictly increasing order.

 

 SOLUTION :

PYTHON CODE :


IMAGE FOR CLEAR  indentation

 

 

CODE 

 

 def minSwaps(arr):
    n = len(arr)
    arrpos = [*enumerate(arr)]
    arrpos.sort(key = lambda it : it[1])
    vis = {k : False for k in range(n)}

    ans = 0
    for i in range(n):
      
        if vis[i] or arrpos[i][0] == i:
            continue
             
       
        cycle_size = 0
        j = i
         
        while not vis[j]:
             
            
            vis[j] = True
             
            
            j = arrpos[j][0]
            cycle_size += 1
             
        if cycle_size > 0:
            ans += (cycle_size - 1)
             
    return ans
 
a=int(input())
arr = list(map(int,input().split()))
print(minSwaps(arr))


 

 

************************************************************************

 

 NON TECH 


 1. Change the following into indirect speech. "What about going for swim," he said, "It's quite fine now."
He asked me what about going for a swim as it was quite fine then
He proposed going for swim as it was quite fine.
He suggested going for a swim as it was quite fine
He advised me to go for a swim as it was quite fine.


2. Change the following into indirect speech. Mohan said, "We shall go to see the Taj in the moonlit night".
Mohan said that we shall go to see the Taj in the moonlit night.
Mohan told that we shall go to see the Taj in moonlit night.
Mohan told that we should go to see the Taj in the moonlit night
Mohan said that they should go to see the Taj in moonlit night


3. Change the following into indirect speech. Manna asked Rohan, "Have you sat in a trolley bus before ?"
Manna asked Rohan had he sat in a trolley bus earlier.
Manna asked Rohan had he sat in a trolley bus before.
Manna asked Rohan if he sat on a trolley bus before
Manna asked Rohan if he has ever sat in a trolley bus


4. Change the following into indirect speech. The government has announced, "Taxes will be raised
The government has announced that taxes would be raised.
The government has announced that taxes would raised
The government has announced that taxes will be raised.
The government has announced taxes will be raised


5. Change the following into indirect speech. The poor examine said, "O God, take pity on me."
The poor examine prayed God to take pity on him.
The poor examine, involving God, implored him to take pity on him.
The poor examine exclaimed that God take pity on him
The poor examine asked God to take pity on him


6 .Change the following into indirect speech. Farhan asked Geeta, "Could you lend me a hundred rupees
until tomorrow ?"
Farhan asked Geeta whether she could lend him a hundred rupees until tomorrow.
Farhan asked Geeta whether she could lend him a hundred rupees until the next day
Farhan asked Geeta whether she could lend me a hundred rupees until the next day.
Farhan asked whether Geeta could lend me a hundred rupees until the next day


7. Change the following into indirect speech. The teacher said to Ram, "Congratulations ! Wish you success
in life."
The teacher congratulated Ram and said wish you success in life.
The teacher wished congratulations and success in life to Ram.
The teacher wished congratulations to Ram and wished him success in life.
The teacher congratulated Ram and wished him success in life


8. Change the following into indirect speech. "Where will you be tomorrow," I said, "in case I have to ring you
?"
I asked where you will be the next day in case I will ring him.
I asked where he would be the next day in case I had to ring him.
I said to him where he will be in case I have to ring him.
I inquired about his where about the next day in case I would have to ring up
 

9. Change the following into indirect speech. The father warned his son that he should be beware of him.
The father warned his son, "beware of him !"
The father warned his son, "Watch that chap !"
The father warned his son, "Be careful about him."
The father warned his son, "Don't fall into the trap."


10. Change the following into indirect speech. He says, ''I don't want to play any more.
He says that he doesn't want to play any more
He says that I don't want to play any more
He says that I didn't want to play any more.
He says that he didn't want to play any more


 

**************************************************************************


Post a Comment

Previous Post Next Post