OneStopGate.Com
OnestopGate   OnestopGate
   Thursday, December 26, 2024 Login  
OnestopGate
Home | Overview | Syllabus | Tutorials | FAQs | Downloads | Recommended Websites | Advertise | Payments | Contact Us | Forum
OneStopGate

GATE Resources
Gate Articles
Gate Books
Gate Colleges 
Gate Downloads 
Gate Faqs
Gate Jobs
Gate News 
Gate Sample Papers
Training Institutes

GATE Overview
Overview
GATE Eligibility
Structure Of GATE
GATE Coaching Centers
Colleges Providing M.Tech/M.E.
GATE Score
GATE Results
PG with Scholarships
Article On GATE
Admission Process For M.Tech/ MCP-PhD
GATE Topper 2012-13
GATE Forum




GATE 2025 Exclusive
Organizing Institute
Important Dates
How to Apply
Discipline Codes
GATE 2025 Exam Structure

GATE 2025 Syllabus
Aerospace Engg..
Agricultural Engg..
Architecture and Planning
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Geology and Geophysics
Instrumentation Engineering
Life Sciences
Mathematics
Mechanical Engg..
Metallurgical Engg..
Mining Engg..
Physics
Production & Industrial Engg..
Pharmaceutical Sciences
Textile Engineering and Fibre Science

GATE Study Material
Aerospace Engg..
Agricultural Engg..
Chemical Engg..
Chemistry
Civil Engg..
Computer Science / IT
Electronics & Communication Engg..
Electrical Engg..
Engineering Sciences
Instrumentation Engg..
Life Sciences
Mathematics
Mechanical Engg..
Physics
Pharmaceutical Sciences
Textile Engineering  and Fibre Science

GATE Preparation
GATE Pattern
GATE Tips N Tricks
Compare Evaluation
Sample Papers 
Gate Downloads 
Experts View

CEED 2013
CEED Exams
Eligibility
Application Forms
Important Dates
Contact Address
Examination Centres
CEED Sample Papers

Discuss GATE
GATE Forum
Exam Cities
Contact Details
Bank Details

Miscellaneous
Advertisment
Contact Us


Home » GATE Study Material » Computer Science » ADA

Analysis,Design And Algorithm

<<Previous Next>>
Divide And Conquer

There are a number of general and powerful computational strategies that are repeatedly used in computer science. It is often possible to phrase any problem in terms of these general strategies. These general strategies are Divide and Conquer, Dynamic Programming. The techniques of Greedy Search, Backtracking and Branch and Bound evaluation are variations of dynamic programming idea. All these strategies and techniques are discussed in the subsequent chapters.

The most widely known and often used of these is the divide and conquer strategy.

The basic idea of divide and conquer is to divide the original problem into two or more sub-problems which can be solved by the same technique. If it is possible to split the problem further into smaller and smaller sub-problems, a stage is reached where the sub-problems are small enough to be solved without further splitting. Combining the solutions of the individuals we get the final conquering. Combining need not mean, simply the union of individual solutions.

Divide and Conquer involves four steps

    1. Divide
    2. Conquer [Initial Conquer occurred due to solving]
    3. Combine
    4. Conquer [Final Conquer].

In precise, forward journey is divide and backward journey is Conquer. A general binary divide and conquer algorithm is :

Procedure D&C (P,Q) //the data size is from p to q

{

If size(P,Q) is small Then

Solve(P,Q)

Else

M ¬ divide(P,Q)

Combine (D&C(P,M), D&C(M+1,Q))

}

Sometimes, this type of algorithm is known as control abstract algorithms as they give an abstract flow. This way of breaking down the problem has found wide application in sorting, selection and searching algorithm.

4.1 Binary Search:

Algorithm:

m¬ (p+q)/2

If (p £ m £ q) Then do the following Else Stop

If (A(m) = Key Then �successful� stop

Else

If (A(m) < key Then

q=m-1;

Else

p¬ m+1

End Algorithm.

Illustration :

Consider the data set with elements {12,18,22,32,46,52,59,62,68}. First let us consider the simulation for successful cases.

Successful cases:

Key=12 P Q m Search

1 9 5 x

1 4 2 x

1 1 1 successful

To search 12, 3 units of time is required

 

Key=18 P Q m Search

1 9 5 x

1 4 2 successful

To search 18, 2 units of time is required

Key=22 P Q m Search

1 9 5 x

1 4 2 x

3 4 3 successful

To search 22, 3 units of time is required

Key=32 P Q m Search

1 9 5 x

1 4 2 x

3 4 3 x

4 4 4 successful

To search 32, 4 units of time is required

Key=46 P Q m Search

1 9 5 successful

To search 46, 1 unit of time is required

Key=52 P Q m Search

1 9 5 x

6 9 7 x

6 6 6 successful

To search 52, 3 units of time is required

Key=59 P Q m Search

1 9 5 x

6 9 7 successful

To search 59, 2 units of time is required

Key=62 P Q m Search

1 9 5 x

6 9 7 x

8 9 8 successful

To search 62, 3 units of time is required

Key=68 P Q m Search

1 9 5 x

6 9 7 x

8 9 8 x

9 9 9 successful

To search 68, 4 units of time is required

 

3+2+3+4+1+3+2+4

Successful average search time= -------------------------

9

unsuccessful cases

Key=25 P Q m Search

1 9 5 x

1 4 2 x

3 4 3 x

4 4 4 x

To search 25, 4 units of time is required

 

 

 

Key=65 P Q m Search

1 9 5 x

6 9 7 x

8 9 8 x

9 9 9 x

To search 65, 4 units of time is required

4+4

Unsuccessful search time =--------------------

2

average (sum of unsuccessful search time

search = + sum of Successful search time)/(n+(n+1))

time

 

 

 

Study Notes Home | Next Section>>

4.1 Divide and Conquer

There are a number of general and powerful computational strategies that are repeatedly used in computer science. It is often possible to phrase any problem in terms of these general strategies. These general strategies are Divide and Conquer, Dynamic Programming. The techniques of Greedy Search, Backtracking and Branch and Bound evaluation are variations of dynamic programming idea. All these strategies and techniques are discussed in the subsequent chapters.

The most widely known and often used of these is the divide and conquer strategy.

The basic idea of divide and conquer is to divide the original problem into two or more sub-problems which can be solved by the same technique. If it is possible to split the problem further into smaller and smaller sub-problems, a stage is reached where the sub-problems are small enough to be solved without further splitting. Combining the solutions of the individuals we get the final conquering. Combining need not mean, simply the union of individual solutions.

Divide and Conquer involves four steps

    1. Divide
    2. Conquer [Initial Conquer occurred due to solving]
    3. Combine
    4. Conquer [Final Conquer].

In precise, forward journey is divide and backward journey is Conquer. A general binary divide and conquer algorithm is :

Procedure D&C (P,Q) //the data size is from p to q

{

If size(P,Q) is small Then

Solve(P,Q)

Else

M ¬ divide(P,Q)

Combine (D&C(P,M), D&C(M+1,Q))

}

Sometimes, this type of algorithm is known as control abstract algorithms as they give an abstract flow. This way of breaking down the problem has found wide application in sorting, selection and searching algorithm.

4.1 Binary Search:

Algorithm:

m¬ (p+q)/2

If (p £ m £ q) Then do the following Else Stop

If (A(m) = Key Then �successful� stop

Else

If (A(m) < key Then

q=m-1;

Else

p¬ m+1

End Algorithm.

Illustration :

Consider the data set with elements {12,18,22,32,46,52,59,62,68}. First let us consider the simulation for successful cases.

Successful cases:

Key=12 P Q m Search

1 9 5 x

1 4 2 x

1 1 1 successful

To search 12, 3 units of time is required

 

Key=18 P Q m Search

1 9 5 x

1 4 2 successful

To search 18, 2 units of time is required

Key=22 P Q m Search

1 9 5 x

1 4 2 x

3 4 3 successful

To search 22, 3 units of time is required

Key=32 P Q m Search

1 9 5 x

1 4 2 x

3 4 3 x

4 4 4 successful

To search 32, 4 units of time is required

Key=46 P Q m Search

1 9 5 successful

To search 46, 1 unit of time is required

Key=52 P Q m Search

1 9 5 x

6 9 7 x

6 6 6 successful

To search 52, 3 units of time is required

Key=59 P Q m Search

1 9 5 x

6 9 7 successful

To search 59, 2 units of time is required

Key=62 P Q m Search

1 9 5 x

6 9 7 x

8 9 8 successful

To search 62, 3 units of time is required

Key=68 P Q m Search

1 9 5 x

6 9 7 x

8 9 8 x

9 9 9 successful

To search 68, 4 units of time is required

 

3+2+3+4+1+3+2+4

Successful average search time= -------------------------

9

unsuccessful cases

Key=25 P Q m Search

1 9 5 x

1 4 2 x

3 4 3 x

4 4 4 x

To search 25, 4 units of time is required

 

 

 

Key=65 P Q m Search

1 9 5 x

6 9 7 x

8 9 8 x

9 9 9 x

To search 65, 4 units of time is required

4+4

Unsuccessful search time =--------------------

2

average (sum of unsuccessful search time

search = + sum of Successful search time)/(n+(n+1))

time

 

 

 

<<Previous Next>>



Discussion Center

Discuss/
Query

Papers/
Syllabus

Feedback/
Suggestion

Yahoo
Groups

Sirfdosti
Groups

Contact
Us

MEMBERS LOGIN
  
Email ID:
Password:

  Forgot Password?
 New User? Register!

INTERVIEW EBOOK
Get 9,000+ Interview Questions & Answers in an eBook. Interview Question & Answer Guide
  • 9,000+ Interview Questions
  • All Questions Answered
  • 5 FREE Bonuses
  • Free Upgrades
GATE RESOURCES
 
  • Gate Books
  • Training Institutes
  • Gate FAQs
  • GATE BOOKS
     
  • Mechanical Engineeering Books
  • Robotics Automations Engineering Books
  • Civil Engineering Books
  • Chemical Engineering Books
  • Environmental Engineering Books
  • Electrical Engineering Books
  • Electronics Engineering Books
  • Information Technology Books
  • Software Engineering Books
  • GATE Preparation Books
  • Exciting Offers



    GATE Exam, Gate 2009, Gate Papers, Gate Preparation & Related Pages


    GATE Overview | GATE Eligibility | Structure Of GATE | GATE Training Institutes | Colleges Providing M.Tech/M.E. | GATE Score | GATE Results | PG with Scholarships | Article On GATE | GATE Forum | GATE 2009 Exclusive | GATE 2009 Syllabus | GATE Organizing Institute | Important Dates for GATE Exam | How to Apply for GATE | Discipline / Branch Codes | GATE Syllabus for Aerospace Engineering | GATE Syllabus for Agricultural Engineering | GATE Syllabus for Architecture and Planning | GATE Syllabus for Chemical Engineering | GATE Syllabus for Chemistry | GATE Syllabus for Civil Engineering | GATE Syllabus for Computer Science / IT | GATE Syllabus for Electronics and Communication Engineering | GATE Syllabus for Engineering Sciences | GATE Syllabus for Geology and Geophysics | GATE Syllabus for Instrumentation Engineering | GATE Syllabus for Life Sciences | GATE Syllabus for Mathematics | GATE Syllabus for Mechanical Engineering | GATE Syllabus for Metallurgical Engineering | GATE Syllabus for Mining Engineering | GATE Syllabus for Physics | GATE Syllabus for Production and Industrial Engineering | GATE Syllabus for Pharmaceutical Sciences | GATE Syllabus for Textile Engineering and Fibre Science | GATE Preparation | GATE Pattern | GATE Tips & Tricks | GATE Compare Evaluation | GATE Sample Papers | GATE Downloads | Experts View on GATE | CEED 2009 | CEED 2009 Exam | Eligibility for CEED Exam | Application forms of CEED Exam | Important Dates of CEED Exam | Contact Address for CEED Exam | CEED Examination Centres | CEED Sample Papers | Discuss GATE | GATE Forum of OneStopGATE.com | GATE Exam Cities | Contact Details for GATE | Bank Details for GATE | GATE Miscellaneous Info | GATE FAQs | Advertisement on GATE | Contact Us on OneStopGATE |
    Copyright © 2024. One Stop Gate.com. All rights reserved Testimonials |Link To Us |Sitemap |Privacy Policy | Terms and Conditions|About Us
    Our Portals : Academic Tutorials | Best eBooksworld | Beyond Stats | City Details | Interview Questions | India Job Forum | Excellent Mobiles | Free Bangalore | Give Me The Code | Gog Logo | Free Classifieds | Jobs Assist | Interview Questions | One Stop FAQs | One Stop GATE | One Stop GRE | One Stop IAS | One Stop MBA | One Stop SAP | One Stop Testing | Web Hosting | Quick Site Kit | Sirf Dosti | Source Codes World | Tasty Food | Tech Archive | Software Testing Interview Questions | Free Online Exams | The Galz | Top Masala | Vyom | Vyom eBooks | Vyom International | Vyom Links | Vyoms | Vyom World
    C Interview Questions | C++ Interview Questions | Send Free SMS | Placement Papers | SMS Jokes | Cool Forwards | Romantic Shayari