PHP Interview Questions
PHP E-books
PHPInterview Questions
Tech Preparation
Carrerride.com
“When it comes to winning, you need the skill and the will.” - Frank Tyger. This blog is an initiative idea to provide the skill and will to win.
Wednesday, September 21, 2011
Tuesday, September 20, 2011
About Wipro
From the Internet the following are the details gathered about the WIPRO.
Profile
Profile
Profile
More on Wipro Questions
Profile
Profile
Profile
More on Wipro Questions
Wipro 2010
WIPRO Paper on 27 March 2010 @ Bangalore
1)APTITUDE TEST:
There was individual cut off for all the sections
Section1- English, 15 questions
Directions 1-5 : Pick out the most effective word from the given words to fill in the blank to make the sentence meaningfully complete
1. While facts are ________ and data hard to come by, even scientists occasionally throw side the professional pretense of
______ and tear into each other with shameless appeals to authority and arguments that shameless appeals to authority and
arguments that are unabashedly ad hominid.
a. elusive...objectivity
b. establish...courtesy
c. demonstrate .. neutrality
d. ineluctable...cooperation
ANS: (A)
2. While the disease is in ______ state it is almost impossible to determine its existence by_____ .
a. a dormant ..postulate
b. a critical...examination
c. an acute ...analysis
d. a latent...observation
ANS: (d)
3. The storehouse was infested.........................rats.
A) by B) of C) with D) in
Ans: C
4. Please distribute these sweets........................the children
A) in B) between C) amid D) among
Ans: D
5. This custom seems to have originated .....................and East European country
A) in B) from C) by D) with
Ans: A
Directions 6-10: The following questions, consist of two words each that have a certain relationship to each other, followed by four lettered pairs of words. Select the lettered pair that has the same relationship as the original pair of words.
6. OFFHAND : PREMEDITATION : :
a. upright : integrity b. aboveboard : guile c. cutthroat : competition d. backward : direction
ANS: (b)
7. POLTERGEIST : APPARATION::
a. dwarf : stature b. witch : familiar c. ogre : monster d. sorcerer : spell
ANS: (c)
8.AVER : AFFIRMATION : :
a. proclaim: objection b. denounce : defiance c. refuse : distress d. demur : protest
ANS. (d)
9. Duralumin : Aircraft
A) Brass : Alloy B) Stone : Sculptor C) Iron : Steel D) Bronze : Statue
Ans: D
10. Cool : Frigid
A) Livid :Lurid B) Pool : Placid C) Tepid : Torried D) Lack : Abundant
Ans : C
Direction 11-13 : In each of the following questions, find out which part of the sentence has an error. if there is no mistake the answer is 'no error'
11. If I was you / I would have / terminated his services then and there / No error
A B C D
Ans : A
12. as soon as I will reach Bombay / I will send / you the books / you have asked for / No error
A B C D E
Ans: A
13. Our conception of / what should a science of mental life be / has changed considerably since James' time / No error
A B C D
Ans : B
Directions 14-15 : In each of the following questions, a sentence has been given in Active (or passive) voice. Out of the four alternatives suggested select the one which best express the same sentence in Passive (or Active) Voice.
14. Do you imitate others ?
A) Are others imitated by you ?
B) Are others being imitated by you ?
C) Were others being imitated by you ?
D) Have others been imitated by you ?
Ans : A
15. I saw him conducting the rehearsal.
A) He was seen conducting the rehearsal
B) I saw the rehearsal to be conducted by him
C) He was seen by me to conduct the rehearsal
D) I saw the rehearsal being conducted by him
Ans : D
Section2-apptitude 15 questions
The questions 1-2 are based on the following data
6 people A,B,C,D,E and F sit around a table for dinner. Since A does not like C, he doesn't sit either opposite or
beside C.B and F always like to sit opposite each other.
1. If A is beside F then who is are the two neighbours of B?
(a) D and C
(b) E and C
(c) D and E
(d) Either (a) or (b)
Ans. (c)
2. If D is adjacent to F then who is adjacent to C?
(a) E and B
(b) D and A
(c) D and B
(d) either (a) or (c)
Ans.(d)
3. Complete the sequence A, E ,I ,M ,Q ,U , _ , _
(a) B, F
(b) Y, C
(c) G, I
(d) K, O
Ans.(b)
4. If the letters of the word "rachit" are arranged in all possible ways and these words are written out as in a dictionary,
what is the rank of the word "rachit".
(a) 485
(b) 480
(c) 478
(d) 481
Ans. (d)
5. Ravi's salary was reduced by 25%.Percentage increase to be effected to bring the salary to the original level is
(a) 20%
(b) 25%
(c) 33 1/3%
(d) 30%
Ans. (c)
6. A and B can finish a piece of work in 20 days .B and C in 30 days and C and A in 40 days. In how many days
will A alone finish the job
(a) 48
(b) 34 2/7
(c) 44
(d) 45
Ans. (a)
7. How long will a train 100m long travelling at 72kmph take to overtake another train 200m long travelling at 54kmph ?
(a) 70sec
(b) 1min
(c) 1 min 15 sec
(d) 55 sec
Ans. (b)
8. What is the product of the irrational roots of the equation (2x-1)(2x-3)(2x-5)(2x-7)=9?
(a) 3/2
(b) 4
(c) 3
(d) 3/4
Ans. (a)
9. The total population of a village is 5000. The number of males and females increases by 10% and 15% respectively
and consequently the population of the village becomes 5600. what was the number of males in the village ?
A) 2000 B) 2500 C) 3000 D) 4000
Ans : C
10. Fresh fruit contains 68% water and dry fruit contains 20% water. How much dry fruit can be obtained from 100 kg
of fresh fruits ?
A) 32 kg B) 40 kg C) 52 kg D) 80 kg
Ans : B
11. If "segment" is coded as rffndou, then "ritual" is coded as
(a) shutbm
(b) qjutbk
(c) qhutbk
(d) qhubtk
Ans. (c)
12. If "football" is "cricket" ,"cricket" is "basketball" ,"basketball" is "volleyball","volleyball" is "khokho" and "khokho" is
cricket, which is not a ball game?
(a) cricket
(b) football
(c) khokho
(d) basketball
Ans. (a)
13. Which of the following is a recursive set of production
(a) S --> a|A, A --> S
(b) S --> a|A, A --> b
(c) S -->aA, A-->S
(d) None of these
Ans. (c)
14. A sum 's' is divided into 4 parts. second person gets Rs 10 more than first.3rd person is Rs 10 more than second,
4th is 10 more than 3rd.how much amount do 1st person get.
Ans: (s-60)/4
15. One ship goes along the stream direction 28 km and in opposite direction 13 km in 5 hrs for each direction. What is the
velocity of stream?
Ans: 1.5 kmph
Section3-technical ,20 questions
1. What sorting algos have their best and worst case times equal ?
Ans. O(nlogn) for mergesort and heap sort
2. What page replacement algorithm has minimum number of page faults ?
Ans. Optimality algorithm
3. What is the use of virtual base class in c++
Ans. Multiple lines between derived classes.
4. Assignment operator targets to _____
Ans. l-value
5. A byte addressable computer has memory capacity of 2 power m Kbytes and can perform 2 power n operations an
instruction involving three operands and one operator needs maximum of___________ bits
Ans. 3m + n
6. In round robin scheduling, if time quantum is too large then it degenerates to
Ans. FCFS
7. What data structures you should use for dictionary searching and it should be capable of doing spell check also ?
Ans: Hashing
8. What is the value of 121 base 4 + 84 base 16 ?
Ans : 2130
9. When the fn. is called where the return address is stored?
Ans. stack
10. C program code
int zap (int n)
{
if (n<=1)then zap=1;
else zap=zap(n-3)+zap(n-1);
}
then the call zap(6) gives the values of zap
[a] 8 [b] 9 [c] 6 [d] 12 [e] 15
Ans: b
11. Virtual memory size depends on
[a] address lines [b] data bus
[c] disc space [d] a & c [e] none
Ans : a
12. Critical section is
Ans: statements which are accessing shared resources
13. In which layer ROUTING is performed ?
Ans. Network Layer
14. What is the output of the following code snippet
main()
{
printf(5+”Fascimile”);
}
Ans. mile
15. Which one has no L-Value
A a[i] B. i C. 2 D. *(a+i)
Ans . C
16. Which is true for binary search ?
A Traversal scheme B. Greedy algorithm
C. Divide and conquer algorithm D. none of these
Ans. C
17. What is the protocol used for getting the physical address by supplying IP address of a node ?
A. ARP B. RARP C. BOOTP D. DHCP
Ans. A
18. Which is not an OS?
a) Win 3.1 b) Win 95
c) Win 98 d) Win 2000
Ans. a
19. Tcp/ip is
a) connectionless b) connection oriented c) both a & b d) none
Ans: b
20. A sorting algorithm which can prove to be a best time algorithm in one case and a worst time algorithm in worst case is
(a) Quick Sort (b) Heap Sort (c) Merge Sort (d) Insert Sort
Ans. (a)
wipro written Test
Wipro written test question paper 28th Feb. 2011 at Hyderabad
1. Given the following statement enum day = { jan = 1 ,feb=4, april, may} What is the value of may?
(a) 4
(b) 5
(c) 6
(d) 11
(e) None of the above
2. Find the output for the following C program
main
{int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);
3. Find the output for the following C program
fn f(x)
{ if(x<=0) > return;
else f(x-1)+x;
}
4. Find the output for the following C program
i=20,k=0;
for(j=1;j {k+=j<10?4:3;> }
printf("%d", k);
Ans. k=4
5. Find the output for the following C program
int i =10
main()
{int i =20,n;
for(n=0;n<=i;) > {int i=10;
i++;
}
printf("%d", i);
Ans. i=20
6. Find the output for the following C program
int x=5;
y= x&y
7.Find the output for the following C program
Y=10;
if( Y++>9 && Y++!=10 && Y++>10)
{printf("%d", Y);
else
printf("%d", Y);
}
Ans. 13
8. Find the output for the following C program
f=(x>y)?x:y
a) f points to max of x and y
b) f points to min of x and y
c)error
Ans. (a)
9. What is the sizeof(long int)
(a) 4 bytes
(b) 2 bytes
(c) compiler dependent
(d) 8 bytes
10. Which of the function operator cannot be over loaded
(a) <= > (b) ?:
(c) ==
(d) *
1. Given the following statement enum day = { jan = 1 ,feb=4, april, may} What is the value of may?
(a) 4
(b) 5
(c) 6
(d) 11
(e) None of the above
2. Find the output for the following C program
main
{int x,j,k;
j=k=6;x=2;
x=j*k;
printf("%d", x);
3. Find the output for the following C program
fn f(x)
{ if(x<=0) > return;
else f(x-1)+x;
}
4. Find the output for the following C program
i=20,k=0;
for(j=1;j {k+=j<10?4:3;> }
printf("%d", k);
Ans. k=4
5. Find the output for the following C program
int i =10
main()
{int i =20,n;
for(n=0;n<=i;) > {int i=10;
i++;
}
printf("%d", i);
Ans. i=20
6. Find the output for the following C program
int x=5;
y= x&y
7.Find the output for the following C program
Y=10;
if( Y++>9 && Y++!=10 && Y++>10)
{printf("%d", Y);
else
printf("%d", Y);
}
Ans. 13
8. Find the output for the following C program
f=(x>y)?x:y
a) f points to max of x and y
b) f points to min of x and y
c)error
Ans. (a)
9. What is the sizeof(long int)
(a) 4 bytes
(b) 2 bytes
(c) compiler dependent
(d) 8 bytes
10. Which of the function operator cannot be over loaded
(a) <= > (b) ?:
(c) ==
(d) *
Wipro Placement Questions
Wipro Placement Paper on 21st April 2011 at Bangalore
1. If a man buys 1 lt of milk for Rs.12 and mixes it with 20% water and sells it for Rs.15, then what is the percentage of gain?
2. Pipe A can fill a tank in 30 mins and Pipe B can fill it in 28 mins.If 3/4th of the tank is filled by Pipe B alone and both are opened, how much time is
required by both the pipes to fill the tank completely ?
3. If on an item a company gives 25% discount, they earn 25% profit. If they now give 10% discount then what is the profit percentage.
4. A certain number of men can finish a piece of work in 10 days. If however there were 10 men less it will take 10 days more for the work to be
finished. How many men were there originally?
5. In simple interest what sum amounts of Rs.1120/- in 4 years and Rs.1200/- in 5 years ?
VERBAL
1. Please distribute these sweets........................the children
2. This custom seems to have originated .....................and East European country
NON VERBAL
1.How long will a train 1km long travelling at 75kmph take to overtake another train 500m long travelling at 94kmph ?
2.The total population of a village is 5500. The number of males and females increases by 80% and 65% respectively
and consequently the population of the village becomes 5600. what was the number of females in the village ?
3.A and B can finish a piece of work in 40 days .B and C in 60 days and C and A in 80 days. In how many days
will B alone finish the job ?
TECHNICAL
1.NVL : Null value function
2.TTITLE & BTITLE: control report headings & footers.
3.COMPUTE: control computations on subsets created by the BREAK command.
4.Minus: product of two tables listing only the non-matching rows.
5.Rollback work in the current transaction to be undone.
6.few differences between Unicode character encoding to that of ASCII.
7.With help of DBMS what is the differences between shared and exclusive locks ?
8.what is the primary difference between applets and conventional web applications ?
9.In the context of memory management schemes what is the primary difference between swapping and paging ?
1. If a man buys 1 lt of milk for Rs.12 and mixes it with 20% water and sells it for Rs.15, then what is the percentage of gain?
2. Pipe A can fill a tank in 30 mins and Pipe B can fill it in 28 mins.If 3/4th of the tank is filled by Pipe B alone and both are opened, how much time is
required by both the pipes to fill the tank completely ?
3. If on an item a company gives 25% discount, they earn 25% profit. If they now give 10% discount then what is the profit percentage.
4. A certain number of men can finish a piece of work in 10 days. If however there were 10 men less it will take 10 days more for the work to be
finished. How many men were there originally?
5. In simple interest what sum amounts of Rs.1120/- in 4 years and Rs.1200/- in 5 years ?
VERBAL
1. Please distribute these sweets........................the children
2. This custom seems to have originated .....................and East European country
NON VERBAL
1.How long will a train 1km long travelling at 75kmph take to overtake another train 500m long travelling at 94kmph ?
2.The total population of a village is 5500. The number of males and females increases by 80% and 65% respectively
and consequently the population of the village becomes 5600. what was the number of females in the village ?
3.A and B can finish a piece of work in 40 days .B and C in 60 days and C and A in 80 days. In how many days
will B alone finish the job ?
TECHNICAL
1.NVL : Null value function
2.TTITLE & BTITLE: control report headings & footers.
3.COMPUTE: control computations on subsets created by the BREAK command.
4.Minus: product of two tables listing only the non-matching rows.
5.Rollback work in the current transaction to be undone.
6.few differences between Unicode character encoding to that of ASCII.
7.With help of DBMS what is the differences between shared and exclusive locks ?
8.what is the primary difference between applets and conventional web applications ?
9.In the context of memory management schemes what is the primary difference between swapping and paging ?
Wipro Questions
WIPRO Interview Questions on 9th January 2011 at Bangalore
Q.1. Consider a string variable stroriginal holding a string value in its memory. Consider the following lines of C code.
strcpy(strdummy,stroriginal);
strreversed = strrev(strdummy);
If stroriginal is a palindrome which of the following statements is true.
a) strcmp(stroriginal,strreversed) is 0
b) strcmp(stroriginal,strrev(strreversed)) is 1
c) strcmp(stroriginal,strreversed) is 1
Answer :- Option a) is the right answer. If the string is a palindrome the strcmp will return 0 while comparing the original and the reversed string.
Q.2. Consider the following lines of C code :
int i,j,summ,lim;
i=0;
j=1;
for(lim = 1; lim <= 10; lim++)
{
summ = j + i;
i = j;
j = sum;
printf("%d",summ);
}
What kind of sequence the above code will generate ?
a) Even Numbers
b) Arithmetic Progression
c) Fibonacci Series
Answer :- The above code would generate option c) Fibonacci Series
Q.3. State True or False. Recursion Type Programming can be used to generate Fibonacci series in C
Answer :- True. Fibonacci series can be generated by recursion programming.
Q.4. Can you say few differences between Unicode character encoding and that of ASCII.
Answer :-Unicode uses 16 bits to encode characters and symbols whereas ASCII uses only 8 bits. Unicode has become a universal standard due to the fact that they can represent far great letters than ASCII. Unicode can be used hassle free to encode several regional languages other than English.
Q.5. With reference to DBMS like Oracle or Sybase, can you tell the differences between shared and exclusive locks ?
Answer :-Multiple transactions use shared locks during database read operations (SELECT Queries) as no data modification is involved. However if a transaction wants to change value of column/columns in single or multiple rows, it acquires an exclusive lock which will not be open to other transactions simultaneously.
Q.6. Can you tell the primary difference between applets and conventional web applications ?
Answer :-Applet is a program that would be downloaded to browser and run on local CPU whereas web applications get executed on server.
Q.7. In the context of memory management schemes, can you tell a primary difference between swapping and paging?
Answer :-Paging refers to writing and reading individual pages (fixed size) of a program to secondary memory (during program execution). Swapping refers to swap an entire program with another in secondary memory during heavy resource utilization.
Q.8. What is RAID ? What is its purpose ?
Answer :- RAID stands for Redundant Array of Independent Disks. It refers to a group of redundant disks (2 or more) which offers fault tolerance towards memory failures.
Q.9.Name the unique address that is stored on ROM on the network adapter card.
Answer :-MAC (Media Access Control) Address is the answer.
Q.10.How to find the maximum number of IPs that can be assigned to a PC.
Answer :-A simple rule to identify the number of NICs or Network Interface Cards. An equal number of IPs can be assigned (provided the OS supports).
Q.11.Tell one good programming requirement that illustrates the fact that C is a strongly typed language ?
Answer :-C involves variable declarations before their usage. This makes it clear that C is strongly typed.
Q.12. Consider a weather report application in C where any change in temperature by +- 2 degrees will be constantly reported to the system and the application should store the times of the day when these changes took place. Which is a better data structure to be used in this scenario - an array or a linked list ?
Answer :-Linked List would handle dynamically growing data very well when compared to arrays. Hence it would be a better choice.
Q.13.Can one use arrays to implement stacks or queues over linked lists ? Is it feasible ?
Answer :-Thought linked lists are commonly used for implementing stacks or queues, with good programming logic, arrays can also be used to implement those. However, as you would expect, linked lists are far more efficient in this scenario.
Q.1. Consider a string variable stroriginal holding a string value in its memory. Consider the following lines of C code.
strcpy(strdummy,stroriginal);
strreversed = strrev(strdummy);
If stroriginal is a palindrome which of the following statements is true.
a) strcmp(stroriginal,strreversed) is 0
b) strcmp(stroriginal,strrev(strreversed)) is 1
c) strcmp(stroriginal,strreversed) is 1
Answer :- Option a) is the right answer. If the string is a palindrome the strcmp will return 0 while comparing the original and the reversed string.
Q.2. Consider the following lines of C code :
int i,j,summ,lim;
i=0;
j=1;
for(lim = 1; lim <= 10; lim++)
{
summ = j + i;
i = j;
j = sum;
printf("%d",summ);
}
What kind of sequence the above code will generate ?
a) Even Numbers
b) Arithmetic Progression
c) Fibonacci Series
Answer :- The above code would generate option c) Fibonacci Series
Q.3. State True or False. Recursion Type Programming can be used to generate Fibonacci series in C
Answer :- True. Fibonacci series can be generated by recursion programming.
Q.4. Can you say few differences between Unicode character encoding and that of ASCII.
Answer :-Unicode uses 16 bits to encode characters and symbols whereas ASCII uses only 8 bits. Unicode has become a universal standard due to the fact that they can represent far great letters than ASCII. Unicode can be used hassle free to encode several regional languages other than English.
Q.5. With reference to DBMS like Oracle or Sybase, can you tell the differences between shared and exclusive locks ?
Answer :-Multiple transactions use shared locks during database read operations (SELECT Queries) as no data modification is involved. However if a transaction wants to change value of column/columns in single or multiple rows, it acquires an exclusive lock which will not be open to other transactions simultaneously.
Q.6. Can you tell the primary difference between applets and conventional web applications ?
Answer :-Applet is a program that would be downloaded to browser and run on local CPU whereas web applications get executed on server.
Q.7. In the context of memory management schemes, can you tell a primary difference between swapping and paging?
Answer :-Paging refers to writing and reading individual pages (fixed size) of a program to secondary memory (during program execution). Swapping refers to swap an entire program with another in secondary memory during heavy resource utilization.
Q.8. What is RAID ? What is its purpose ?
Answer :- RAID stands for Redundant Array of Independent Disks. It refers to a group of redundant disks (2 or more) which offers fault tolerance towards memory failures.
Q.9.Name the unique address that is stored on ROM on the network adapter card.
Answer :-MAC (Media Access Control) Address is the answer.
Q.10.How to find the maximum number of IPs that can be assigned to a PC.
Answer :-A simple rule to identify the number of NICs or Network Interface Cards. An equal number of IPs can be assigned (provided the OS supports).
Q.11.Tell one good programming requirement that illustrates the fact that C is a strongly typed language ?
Answer :-C involves variable declarations before their usage. This makes it clear that C is strongly typed.
Q.12. Consider a weather report application in C where any change in temperature by +- 2 degrees will be constantly reported to the system and the application should store the times of the day when these changes took place. Which is a better data structure to be used in this scenario - an array or a linked list ?
Answer :-Linked List would handle dynamically growing data very well when compared to arrays. Hence it would be a better choice.
Q.13.Can one use arrays to implement stacks or queues over linked lists ? Is it feasible ?
Answer :-Thought linked lists are commonly used for implementing stacks or queues, with good programming logic, arrays can also be used to implement those. However, as you would expect, linked lists are far more efficient in this scenario.
Monday, September 19, 2011
Wipo Interview Questions Technical
Some of the Wipro placement papers are available at : Entrance.net
- What is the major expressions used with find command to select file which has been accessed more than 375 days ago?
- What are the desirable attributes for memory managment?
- What is the name given to the process of initializing a micro computer with its OS?
- What action does a typical user defined signal handler functions perform?
- Which constructor is invalid for class cat?
- How will you remove a file with the name '-somethink'?
- What is the output of the following code - What is the output of the following code int i=7;printf("%d", i++ * i++);
- What is the difference between Switch and Hub ?
- Explain applet life cycle?
- What is the difference between C and ANSI C?
- What is RSTP & MSTP?
- Which polarity will you prefer for SMAW & why?
- Why java does not support multiple inheritence?2.what is the difference b/w structures and classes?
- What is the part of compiler that keeps track of names and their attributes? A) Compile Table B)Symbol
- Which constructor is invalid for class cat?A) void cat :: cat() { feet=4;} B) cat::cat(int f){feet=f;}C)
- Which of the following operators cannot be overloaded in C++? A) ?: B)[] C) -
- Add 79H and 86H and tell the contents of flag
- Is QTP Supports Sunsolaries and Sybase?
- What is the output of the program? int n=f,m; n==m++; m==++n; printf(n, m);
- What is the method of connecting two physically separate LAN by using internet
- Which is layer 3 connection less protocol? A. IP B. ARP C. TCP D. UDP
- What is the output? int i=7 printf("%dn",i++*i++);
- What does USB stands for?
- What does ISDN stand for?
- In windows file menu can be invoked by? Alt+F keys What are the three components of OS?
- What is boot PROM?
- Which is the Database used in IBM mainframes?
3. What are the unusual patterns of SDLC?
4. Differentiate between Spiral and Incremental model?
5. What is the disadvantage of Incremental model? Give an model to explain.
6. What do you merciless by the Design phase? What are the weapons this can be depleted in such a phase?
7. Coming to C, how is hashing? Why do we use hashing and not arrays? How do we commence a Hash table?
8. What are function pointers? Give the syntax for the same.
9. Why do we use pointers in C at all?
10. You appreciate just about residences and union. Why is Union used? Give a true livlihood ideal in that you’ll use union?
11. What is SSL?
12. What is the change between HTTP and HTTPS?
4. Differentiate between Spiral and Incremental model?
5. What is the disadvantage of Incremental model? Give an model to explain.
6. What do you merciless by the Design phase? What are the weapons this can be depleted in such a phase?
7. Coming to C, how is hashing? Why do we use hashing and not arrays? How do we commence a Hash table?
8. What are function pointers? Give the syntax for the same.
9. Why do we use pointers in C at all?
10. You appreciate just about residences and union. Why is Union used? Give a true livlihood ideal in that you’ll use union?
11. What is SSL?
12. What is the change between HTTP and HTTPS?
Wednesday, September 7, 2011
Insertion Sort
Demo Insertion Sort
Insertion Sort:
Insertion sorting algorithm is similar to bubble sort. But insertion sort is
more efficient than bubble sort because in insertion sort the elements
comparisons are less as compare to bubble sort. In insertion sorting algorithm compare
the value until all the prior elements are lesser than compared value is
not found.
This mean that the all previous values are lesser than compared value.
This algorithm is more efficient than the bubble sort .Insertion sort is a good choice for small
values and for nearly-sorted values. There are more efficient algorithms such as
quick sort, heap sort, or merge sort for large values .
Positive feature of insertion sorting: 1.It is simple to implement
2.It is efficient on (quite) small data values
3.It is efficient on data sets which are already nearly sorted.
The complexity of insertion sorting is O(n) at best case of an already sorted array and O(n2) at worst case .
Code description:
In insertion sorting take the element form left assign value into a
variable. Then compare the value with previous values. Put
value so that values must be lesser than the previous values. Then assign
next value to a variable and follow the same steps relatively until the comparison
not reached to end of array.
Working of insertion sorting:
Program
#include"stdio.h"
void main()
{
int A[20], N, Temp, i, j;
printf("\n\n\t ENTER THE NUMBER OF TERMS...: ");
scanf("%d", &N);
printf("\n\t ENTER THE ELEMENTS OF THE ARRAY...:");
for(i=0; i
scanf("\n\t\t%d", &A[i]);
}
for(i=1; i
Temp = A[i];
j = i-1;
while(Temp=0)
{
A[j+1] = A[j];
j = j-1;
}
A[j+1] = Temp;
}
printf("\n\tTHE ASCENDING ORDER LIST IS...:\n");
for(i=0; i
}
Output
Subscribe to:
Posts (Atom)