Questions

Q:

Write a c program for quick sort.

Answer

#include<stdio.h>

void quicksort(int [10],int,int);

int main(){
  int x[20],size,i;

  printf("Enter size of the array: ");
  scanf("%d",&size);

  printf("Enter %d elements: ",size);
  for(i=0;i<size;i++)
    scanf("%d",&x[i]);

  quicksort(x,0,size-1);

  printf("Sorted elements: ");
  for(i=0;i<size;i++)
    printf(" %d",x[i]);

  return 0;
}

void quicksort(int x[10],int first,int last){
    int pivot,j,temp,i;

     if(first<last){
         pivot=first;
         i=first;
         j=last;

         while(i<j){
             while(x[i]<=x[pivot]&&i<last)
                 i++;
             while(x[j]>x[pivot])
                 j--;
             if(i<j){
                 temp=x[i];
                  x[i]=x[j];
                  x[j]=temp;
             }
         }

         temp=x[pivot];
         x[pivot]=x[j];
         x[j]=temp;
         quicksort(x,first,j-1);
         quicksort(x,j+1,last);

    }
}

Output:
Enter size of the array: 5
Enter 5 elements: 3 8 0 1 2
Sorted elements: 0 1 2 3 8

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

0 2753
Q:

Which of the following team has won the 37th and final edition of the Hockey Champions Trophy at Breda, the Netherlands?

A) India B) Australia
C) Brazil D) The Netherlands
 
Answer & Explanation Answer: B) Australia

Explanation:

In the summit clash of the 37th and final edition of the Hockey Champions Trophy at Breda, the Netherlands, India lost to defending champions Australia via penalty shoot-off. The match went into the shoot-off after both the teams were locked at 1-1 in regulation time.

Report Error

View Answer Report Error Discuss

Filed Under: Sports
Exam Prep: AIEEE , Bank Exams , CAT , GATE
Job Role: Analyst , Bank Clerk , Bank PO

0 2752
Q:

When did B.R. Ambedkar was received Bharat Ratna?

A) 1890 B) 1980
C) 1990 D) 1989
 
Answer & Explanation Answer: C) 1990

Explanation:

Dr. B.R. Ambedkar received Bharat Ratna in the year 1990.

Report Error

View Answer Report Error Discuss

Filed Under: Indian History
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

3 2752
Q:

If there is a lock on an adjacent key, an insert will fail if the isolation level is set to what?

A) committed read B) repeatable read
C) share read D) indexed read
 
Answer & Explanation Answer: B) repeatable read

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: IBM Certification

1 2752
Q:

Improve the bracketed part of the sentence.
If (you will approach) her sincerely, she will listen to your problem definitely.

A) you approach B) you are approaching
C) you will be approaching D) No improvement
 
Answer & Explanation Answer: A) you approach

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: English
Exam Prep: Bank Exams

0 2752
Q:

Which is a correct way to measure wavelength?

A) Nearest peak to peak B) Nearest peak to nearest trough
C) Nearest trough to peak D) None of the above
 
Answer & Explanation Answer: A) Nearest peak to peak

Explanation:

Wavelength of a wave can be measured with the distance between two nearest crest and crest or nearest troughs. It is measured as armstrong units.

Report Error

View Answer Report Error Discuss

Filed Under: Physics
Exam Prep: AIEEE , Bank Exams , CAT , GATE
Job Role: Analyst , Bank Clerk , Bank PO

2 2751
Q:

The sources of state power are specifically outlined in

A) The Tenth Amendment B) The supremacy clause
C) Article l D) All of the above
 
Answer & Explanation Answer: A) The Tenth Amendment

Explanation:

The sources of state power are specifically outlined in the Tenth Amendment of the Bill of Rights.
When the Constitution was first proposed, many people were concerned about the federal government become too powerful. A group known as the anti-federalists pushed for a way to legally set aside certain rights and powers to individual states.

This amendment was added to satisfy the anti-federalists who were concerned that the Constitution would grant the federal government unlimited power.

 

The Tenth Amendment states that all powers that are not specifically given to the federal government are reserved to individual states.

Report Error

View Answer Report Error Discuss

Filed Under: Indian Politics
Exam Prep: AIEEE , Bank Exams , CAT
Job Role: Analyst , Bank Clerk , Bank PO

2 2751
Q:

Ticks and mites are actually

A) Arachnids B) Insects
C) Myriapods D) Crustaceans
 
Answer & Explanation Answer: A) Arachnids

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: General Science
Exam Prep: AIEEE , Bank Exams , GATE
Job Role: Analyst , Bank Clerk , Bank PO

7 2751