Exforsys

Free Training

Highlight the Purpose

This is a discussion on Highlight the Purpose within the C and C++ forums, part of the Programming Talk category; I saw two functions qsort() and bsearch() recently in one C book. But I could not get the usage of ...

Go Back   Exforsys > Programming Talk > C and C++

Exforsys.com


C and C++ C and C++

Reply

 

LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 12-18-2006, 02:34 AM
Senior Member
 
Join Date: Apr 2006
Posts: 162
sammy is on a distinguished road
Highlight the Purpose

I saw two functions qsort() and bsearch() recently in one C book. But I could not get the usage of this. What is the purpose of these functions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-14-2007, 04:57 PM
Senior Member
 
Join Date: Apr 2006
Posts: 125
ashlee is on a distinguished road
qsort function is used for sorting elements in an array given. It takes parameter as pointer to first element of the array given for sorting, the size of each of the array element in bytes, number of elements in array, pointer to elements of array.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-22-2007, 08:38 AM
Junior Member
 
Join Date: May 2007
Posts: 9
hvg_99 is on a distinguished road
Hightlight the purpose..qsort() & bsearch()

Hi,

qsort() function is used to sort a big array or a linked list. It is a kind of sorting where a key is found out by using some formula and is placed at the center of the array. Then you sort the array using some logic. If you want i can explain with an example.

bsearch() function is used to search for an element in the array. There are basically two types of searches.

1. Linear search
2. Binary Search ( bsearch())

For linear search you keep search for an element irrespective of the array is sorted or not. but in case of binary search the pre requisite is that the array must be in sorted in order, if not then first thing is to sort the array and then perform the search. I can also explain this also.

As your query was just to know the purpose of these two functions so i did not explain with an example. If you really feel i can explain them with an example.

I hope i have cleared your doubt.

Regards,
Bangalore
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-24-2007, 04:29 PM
Senior Member
 
Join Date: Apr 2006
Posts: 162
sammy is on a distinguished road
I could get a clear overview about qsort() function and bsearch() function. If you could explain them with an example it would help me further to understand these concepts in detail.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Highlight on Drawback Ralph MySQL 2 04-11-2007 06:28 AM
Which has higher priority- Somebody throw highlight on this? Allan C and C++ 1 04-07-2007 09:12 AM
Highlight the Difference priyaraji Oracle Database 2 12-14-2006 06:11 AM
comp.archives.ms-windows.{announce,discuss} FAQ Timo Salmi Tech FAQ 0 06-04-2004 08:06 AM
comp.archives.ms-windows.{announce,discuss} FAQ Timo Salmi Tech FAQ 0 05-04-2004 08:06 AM


All times are GMT -4. The time now is 10:33 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0
Copyright 2004 - 2009 Exforsys Inc. All rights reserved.