GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Concepts  >  Data Structures
Go To First  |  Previous Question  |  Next Question 
 Data Structures  |  Question 164 of 202    Print  
the number of swappings needed to short the numbers
8, 22, 7, 9, 31, 19, 5, 13 in ascending order using bubble sort is

1. 11 2. 12 3. 13 4. 14

  
Total Answers and Comments: 2 Last Update: March 13, 2007     Asked by: Rujul 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 12, 2007 20:28:04   #1  
Ashish Parik        

RE: the number of swappings needed to short the number...
14 swapings r req. in case of bubble sort

 
Is this answer useful? Yes | No
March 13, 2007 12:47:34   #2  
Ranjan Kumar Ojha        

RE: the number of swappings needed to short the number...
ans will be 14. you can check.

#include<iostream>
using namespace std;
int main()
{
int a[] { 8 22 7 9 31 19 5 13 };int counter 0;
for(int i 0;i<8;i++)
{
for(int j 0;j<8-i-1;j++)
{
if(a[j]>a[j+1])
{
int t a[j];
a[j] a[j+1];
a[j+1] t;
counter++;
}
}
}
//for(int i 0;i<8;i++)
//cout<<a[i]<<" ";
cout<<"n"<<counter;
system("pause");
return 0;
}

 
Is this answer useful? Yes | No

 Related Questions

An _________ data type is a keyword of a programming language that specifies the amount of memory needed to store data and the kind of data that will be stored in that memory location.
Skill/Topic: Memory, Abstract Data Types, and AddressesA) abstract 

Skill/Topic: Memory, Abstract Data Types, and AddressesA) ShortB) IntC) floatD) longExplanation: The integer abstract data type group consists of four abstract data types used to reserve memory to store 
Latest Answer : float ...
Tags : Abstract

Skill/Topic: Memory, Abstract Data Types, and AddressesA) TrueB) FalseExplanation: The sign takes up 1 bit of memory that could otherwise be used to represent a value. For example, a byte has 8 bits, all 
Latest Answer : True: signed numbers just use 2's complement format, both signed and 2's complement take the same amount of memory. The information about the sign is just hidden in algorithm of 2's complement format, if the first bit is 1 it is negative (but ...

Priority queue organizes items in a line where the first item is at the beginning of the line and the last item is at the back of the line.
Skill/Topic: QueueA) TrueB) FalseExplanation: A simple queue organizes items in a line where the first item is at the beginning of the line and the last item is at the back of the line. Each item is processed 

Skill/Topic: Linked ListA) TrueB) FalseExplanation: displayNodes() method displays the linked list in natural order in the order of Left to Right  

Skill/Topic: Linked ListA) The displayNodesReverse() member function displays the contents of a linked list in reverse order, beginning with the node at the back of the linked list and continuing until 
Latest Answer : To display the content in reverse Order. ...

Identify the error in the following example of the use of a displayNodesReverse() member function void displayNodesReverse(){ cout
Skill/Topic: Linked ListA) Syntax of displayNodesReverse() is wrongB) Node*temp should be NULLC) Wrong use of paranthesisD) temp should be equal to temp->previous Explanation: The displayNodesReverse() 

Skill/Topic: Stacks using Linked ListA) ZeroB) Same as linked listC) Any NumbersExplanation: There can be a nearly unlimited number of nodes on a stack-linked list, restricted only by the amount of available 
Latest Answer : Because this is linked list, you can create any number of nodes. ...

The benefit of using a stack-linked list is that the number of nodes on the stack can increase or decrease as needed while the program runs.
Skill/Topic: Stacks using Linked ListA) TrueB) False 

Skill/Topic: TreeA) number of nodes on the treeB) number of levels of a treeC) Number of branches 
Latest Answer : ans B. ...


 Sponsored Links

 
Related Articles

Breaking up XML into Relational Data

Breaking up XML into Relational Data While the preceding example shows how to construct an XML representation over relational data the example in this section illustrates how you can shred XML data back into relational data This reverse operation can be useful if your application works with relation
 

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Retrieving XML Data

Retrieving XML DataTo retrieve XML data from an XMLType table you can use a SELECT SQL statement just as you would if you had to query a relational table For example to select the employee with the id set to 100 from the employees XMLType table discussed in the preceding section you might issue the
 

Using XMLType for Handling XML Data in the Database

Using XMLType for Handling XML Data in the Database Being an object type XMLType can not only be used to store XML data in the database but also to operate on that data via its built in methods Regardless of the storage model you choose XMLType provides a set of XML specific methods to operate on XM
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

ODP.NET - Techniques to Improve Performance while Retrieving Data

ODP NET Techniques to Improve Performance while Retrieving Data Performance tuning is a great subject in Oracle Volumes of books would not be enough to cover every aspect of performance tuning in Oracle However in this section we will only discuss the fundamental performance techniques while working
 

ODP.NET - Populating a Dataset with a Single Data Table

ODP NET Populating a Dataset with a Single Data Table A dataset is simply a group of data tables These data tables can be identified with their own unique names within a dataset You can also add relations between data tables available in a dataset mosgoogle The following code gives you the details o
 

ODP.NET - Retrieving Typed Data

ODP NET Retrieving Typed Data While retrieving values from OracleDataReader we can extract information available in individual columns of a particular row either by using column ordinal position values or column names mosgoogle Retrieving Typed Data Using Ordinals ODP NET provides data specific enum
 

ODP.NET - Retrieving Data Using OracleDataReader

ODP NET Retrieving Data Using OracleDataReader OracleDataReader is simply a read only and forward only result set It works only if the database connection is open and it makes sure that the connection is open while you are retrieving data As the data that it retrieves is read only it is a bit faster
 

ODP.NET - Fundamental ODP.NET Classes to Retrieve Data

ODP NET Fundamental ODP NET Classes to Retrieve Data To retrieve data from an Oracle database using ODP NET we need to work with a few of the ODP NET classes At this point we will discuss the most fundamental classes available in ODP NET for retrieving data mosgoogle The following is the list of fun
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape