Showing posts with label recursive algorithms. Show all posts
Showing posts with label recursive algorithms. Show all posts

Friday, 27 October 2017

Saturday, 21 October 2017

Concurrent Quick Sort Class in OpenMP

Q: Design a class for concurrent quicksort in C++.

Decided to use OpenMp since Pthread doesn't work well with classes, not without ton's of efforts.

Friday, 20 October 2017

Recursive & Iterative Binary Search in Scala

Scala

My very first program in Scala. And I don't find Scala close to Java. I am quite used to Java and C++ and rather find the two more close as very as programming is concerned.

Scala however is closer to Java since scala code is converted to Java Bytecode and the executed.

Program

I used 2 classes a Binary Search class & a Tester object
. An object is more like a singleton class according to my understanding. 
The BinarySearch class has constructor which accepts a sorted array.
It has 2 functions 
  1. A Recursive Binary Search
  2. An Iterative Binary Search.

Monday, 3 July 2017

Summing the digits of a number in C++

Q: This is a simple ad-hoc problem which asks to sum up the digits of a number repeatedly until the sum is less than 10. We are required to stop the program when input given is 0.


Monday, 1 February 2016

Powerset Generator Recursive Algorithm Python

 Q:Write a python program to generate powerset for given set of elements.

Truth Value Generator-Recursive Algorithms-Python

Q:- Write a Python Program to generate all possible truth values for a given number of boolean variables

Tower of Hanoi-Solution

python-tower-of-hanoi The Game

Tower of Hanoi is a puzzle game. Your objective is to move disks from one tower to another tower. You initially have 3 towers of which two are empty and one(say tower 1) contains n disks. These n disks are all of different sizes. In tower 1 they are present in definite order- the largest at the botttom and the smallest at the top. You can only move one disk at a time. The rule is that you cannot place a bigger disk on a smaller disk. This relocation of disks needs to be done in minimum number of moves.