Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Recursion and Backtracking Problems: Solutions and Practice, Study notes of Computer Science

A collection of recursion and backtracking problems with their solutions and practice links. Topics include reversing strings and stacks, checking palindromes, generating binary strings, finding combinations and permutations, and solving various puzzles and maze problems using recursion and backtracking.

What you will learn

  • How to check if a number is a palindrome using recursion?
  • How to print all palindromic partitions of a string using recursion?
  • How to generate all binary strings without consecutive 1’s using recursion?
  • How to reverse a string using recursion?
  • How to reverse a stack using recursion?

Typology: Study notes

2013/2014

Uploaded on 09/21/2021

sakshi-sharma-26
sakshi-sharma-26 🇮🇳

5 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Recursion*and*Backtracking*Questions:*
*
Reverse*a*string*using*recursion*
[Practice*here:*https://www.geeksforgeeks.org/reverse-a-string-using-recursion/*]*
*
Reverse*a*Stack*using*recursion*
[Practice*here:*https://www.geeksforgeeks.org/reverse-a-stack-using-recursion/*]*
*
Check*if*a*number*is*Palindrome*or*not*
[Practice*here:*https://practice.geeksforgeeks.org/problems/palindrome/0*]*
*
Given*a*string,*print*all*palindromic*partitions*
[Practice*here:*https://www.geeksforgeeks.org/given-a-string-print-all-possible-
palindromic-partition/*]*
*
Generate*all*binary*strings*without**consecutive*1’s*
[Practice*here:*https://www.geeksforgeeks.org/generate-binary-strings-without-
consecutive-1s/*]*
*
All*possible*binary*numbers*of*length*n*with*equal*sum*in*both*halves*
[Practice*here:*https://www.geeksforgeeks.org/all-possible-binary-numbers-of-
length-n-with-equal-sum-in-both-halves/*]*
*
Combinations*in*a*String*of*Digits*
[Practice*here:*https://www.geeksforgeeks.org/combinations-string-digits/*]*
*
Count*consonants*in*a*string*(Iterative*and*recursive*methods)*
[Practice*here:*https://www.geeksforgeeks.org/count-consonants-string-iterative-
recursive-methods/*]*
*
Program*for*length*of*a*string*using*recursion*
[Practice*here:*https://www.geeksforgeeks.org/program-for-length-of-a-string-using-
recursion/*]*
*
Program*for*length*of*a*string*using*recursionFirst*uppercase*letter*in*a*
string*(Iterative*and*Recursive)*
[Practice*here:*https://www.geeksforgeeks.org/first-uppercase-letter-in-a-string-
iterative-and-recursive/*]*
*
Power*Set*in*Lexicographic*order*
[Practice*here:*https://www.geeksforgeeks.org/powet-set-lexicographic-order/*]*
*
pf3
pf4
pf5

Partial preview of the text

Download Recursion and Backtracking Problems: Solutions and Practice and more Study notes Computer Science in PDF only on Docsity!

Recursion and Backtracking Questions:

  • Reverse a string using recursion [Practice here: https://www.geeksforgeeks.org/reverse-a-string-using-recursion/ ]
  • Reverse a Stack using recursion [Practice here: https://www.geeksforgeeks.org/reverse-a-stack-using-recursion/ ]
  • Check if a number is Palindrome or not [Practice here: https://practice.geeksforgeeks.org/problems/palindrome/0 ]
  • Given a string, print all palindromic partitions [Practice here: https://www.geeksforgeeks.org/given-a-string-print-all-possible- palindromic-partition/ ]
  • Generate all binary strings without consecutive 1’s [Practice here: https://www.geeksforgeeks.org/generate-binary-strings-without- consecutive-1s/ ]
  • All possible binary numbers of length n with equal sum in both halves [Practice here: https://www.geeksforgeeks.org/all-possible-binary-numbers-of- length-n-with-equal-sum-in-both-halves/ ]
  • Combinations in a String of Digits [Practice here: https://www.geeksforgeeks.org/combinations-string-digits/ ]
  • Count consonants in a string (Iterative and recursive methods) [Practice here: https://www.geeksforgeeks.org/count-consonants-string-iterative- recursive-methods/ ]
  • Program for length of a string using recursion [Practice here: https://www.geeksforgeeks.org/program-for-length-of-a-string-using- recursion/ ]
  • Program for length of a string using recursionFirst uppercase letter in a

string (Iterative and Recursive)

[Practice here: https://www.geeksforgeeks.org/first-uppercase-letter-in-a-string- iterative-and-recursive/ ]

  • Power Set in Lexicographic order [Practice here: https://www.geeksforgeeks.org/powet-set-lexicographic-order/ ]
  • Print all possible combinations of r elements in a given array of size n [Practice here: https://www.geeksforgeeks.org/print-all-possible-combinations-of-r- elements-in-a-given-array-of-size-n/ ]
  • Print all increasing sequences of length k from first n natural numbers [Practice here: https://www.geeksforgeeks.org/print-increasing-sequences-length-k- first-n-natural-numbers/ ]
  • Program to find the minimum (or maximum) element of an array [Practice here: https://www.geeksforgeeks.org/program-find-minimum-maximum- element-array/ ]
  • Recursive function to delete k-th node from linked list [Practice here: https://www.geeksforgeeks.org/recursive-function-delete-k-th-node- linked-list/ ]
  • Reverse a Doubly linked list using recursion [Practice here: https://www.geeksforgeeks.org/reverse-doubly-linked-list-using- recursion/ ]
  • Find middle of singly linked list Recursively [Practice here: https://www.geeksforgeeks.org/find-middle-singly-linked-list- recursively/ ]
  • Print all leaf nodes of a Binary Tree from left to right [Practice here: https://www.geeksforgeeks.org/print-leaf-nodes-left-right-binary- tree/ ]
  • Recursive Insertion Sort

[Practice here: https://www.geeksforgeeks.org/recursive-insertion-sort/ ]

  • Print a pattern without using any loop [Practice here: https://practice.geeksforgeeks.org/problems/print-pattern/0 ]
  • Print sums of all subsets of a given set [Practice here: https://practice.geeksforgeeks.org/problems/subset-sums/0 ]
  • Count ways to express a number as sum of powers [Practice here: https://www.geeksforgeeks.org/count-ways-express-number-sum- powers/ ]

Backtracking Problems:

  • Rat in a maze Problem [Practice here: https://practice.geeksforgeeks.org/problems/rat-in-a-maze-problem/ ]
  • Printing all solutions in N-Queen Problem

[Practice here: https://www.geeksforgeeks.org/printing-solutions-n-queen-

problem/ ]

  • Word Break Problem using Backtracking [Practice here: https://www.geeksforgeeks.org/word-break-problem-using- backtracking/ ]
  • Remove Invalid Parentheses [Practice here: https://www.geeksforgeeks.org/remove-invalid-parentheses/ ]
  • Match a pattern and String without using regular expressions [Practice here: https://www.geeksforgeeks.org/match-a-pattern-and-string-without- using-regular-expressions/ ]
  • Find paths from corner cell to middle cell in maze [Practice here: https://www.geeksforgeeks.org/find-paths-from-corner-cell-to-middle- cell-in-maze/ ]
  • Sudoku Solver [Practice here: https://practice.geeksforgeeks.org/problems/solve-the-sudoku/0 ]
  • m Coloring Problem [Practice here: https://practice.geeksforgeeks.org/problems/m-coloring-problem/0 ]
  • Hamiltonian Cycle [Practice here: https://practice.geeksforgeeks.org/problems/hamiltonian-path/0 ]
  • Find if there is a path of more than k length from a source

[Practice here: https://www.geeksforgeeks.org/find-if-there-is-a-path-of-more-than-k-

length-from-a-source/ ]

  • Find shortest safe route in a path with landmines [Practice here: https://www.geeksforgeeks.org/find-shortest-safe-route-in-a-path- with-landmines/ ]
  • Partition of a set into K subsets with equal sum [Practice here: https://practice.geeksforgeeks.org/problems/partition-array-to-k- subsets/1 ]
  • Longest Possible Route in a Matrix with Hurdles [Practice here: https://www.geeksforgeeks.org/longest-possible-route-in-a-matrix- with-hurdles/ ]
  • Print all palindromic partitions of a string [Practice here: https://www.geeksforgeeks.org/print-palindromic-partitions-string/ ]
  • Print all possible paths from top left to bottom right of a mXn matrix [Practice here: https://www.geeksforgeeks.org/print-all-possible-paths-from-top-left- to-bottom-right-of-a-mxn-matrix/ ]
  • Subset Sum Problem [Practice here: https://practice.geeksforgeeks.org/problems/subset-sum-problem/0 ]
  • The Knight’s tour problem [Practice here: https://www.geeksforgeeks.org/the-knights-tour-problem- backtracking-1/ ]
  • Warnsdorff’s algorithm for Knight’s tour problem [Practice here: https://www.geeksforgeeks.org/warnsdorffs-algorithm-knights-tour- problem/ ]
  • Tug of War

[Practice here: https://www.geeksforgeeks.org/tug-of-war/ ]