Showing posts with label Advanced problems. Show all posts
Showing posts with label Advanced problems. Show all posts

Heap Sort

Problem statement
Write a c program to sort numbers using heap sort(using max heap)

Generating permutation of characters

Problem statement
Write a c program to print all the permutation of given set of number

Finding k th element by quick sort

Problem statement
Write a c program to find kth element in an array without fully sorting the array
(hint: use quick sort )

Storing numbers in a link list in decreasing order

Problem statement
Write a c program to store numbers in link list in decreasing order,
your program should also print them

Train reservation of ten trains

Problem statement
Write a c program to manage reservation list of ten trains, your program should reserve a ticket,delete a ticket,print ticket,print the reservation chart,your program should take the train number and train name as an input from user,

Reservation of train using recursion

 Problem statement
Write a c RECURSIVE program to maintain reservation list of a train using link list,your program should do the following it should take the name,age,sex as input of a passenger, there are 50 seats in the train,and you can take up to 20 waiting list.
[Click here for non recursive]

Train reservation of one train

Problem statement
Write a c program to maintain reservation list of a train using link list,your program should do the following it should take the name,age,sex as input of a passenger, there are 50 seats in the train,and you can take up to 20 waiting list.
[click here for recursive]

Value of natural log of a number

problem statement
Write a C program that reads a positive number x and computes an approximate value of ln x. The program should have two functions: int main() and double myLn(double x).
Do not use any mathematical library function or any array.
The iterative computation may be done 

ln(x)/2=(x-1)/(x+1)+(1/3)*((x-1)/(x+1))^3+(1/5)((x-1)/(x+1))^5+... so on

hence T(n)= y if n=1
                      
                      y^2T(n-1)   if n>1

Number Operations

Problem statement
Write a c program to do the following
1. int sumdigits (int num) : This function should take a decimal number as input and return the sum of digits
of the number.
2. int reverse (int num) : This function should take a decimal number and return the reverse number.
3. int palindrome (int num) : This function should return 1 if the input decimal number is a palindrome and
0 otherwise.
4. void findcommondigits (int num1, int num2) : This function should print the digits that are
common in two decimal numbers num1 and num2.
a. [Helper function] int occursdigit (int digit, int num) : This function checks if digit (0<=digit<=9) is
a digit in the decimal number num1
Type the following C program to test the above functions

Printing combination of given size from given array


Problem statement
Write a c program to first take inputs from user, then print all the possible sub set of given size(the size will also be given by user)

Sorting with Maintaining order of positive and negative number

Problem Statement
You are required to write an iterative function which takes an integer array and arranges
its elements without using any extra array so that all the negative numbers precede all
the non-negative ones without disturbing the relative order among the negative ones
and similarly that among the non-negative ones. For example,
if the input array is 19 -23 17 2 -11 16 18 -4, then
the returned array is -23 -11 -4 19 17 16 18.

Binary Search using Recursion

Problem Statement
Write a recursive c program to search an element using binary search

Searching an element using Binary Search

Problem Statement
Write a C program to search a element in an array using Binary Search method

Array Operation

Problem statement
Write a c program to do the following
Takes inputs from use and stores them in an array
search() :search an element in the array
sinsert(): insert a element in the array
sdelete(): deletes given element from the array
printarray(): prints the array
intersection(): takes three array and stores intersection of two arrays in the third array
difference():takes three array and stores that element in the third array which are not common in two arrays

Printing Prime Numbers and calculating HCF

Problem Statement
1.In main() read two distinct positive integers s and l, s < l. Do not expect that the user
   provides them in any specific order.
2.Compute the sum of the integers ≤ s and not relatively prime to l. Print the sum and the count
   of these integers.
   s l sum count numbers
   10 18 42 7 {2, 3, 4, 6, 8, 9, 10}
    27 55 108 7 {5, 10, 11, 15, 20, 22, 25}
2. Write a recursive function int isPrime(int n, int fp) to test whether the first parameter n, a positive int data, is prime. The function returns 1 if n is a prime, otherwise it
returns 0. When isPrime() is called for the first time, two (the first prime number) is pas sed
as the second parameter. [Your function should not contain any loop construct. You get 50%
credit if you write an iterative function.]
3. Write a non-recursive function int printPrime(int s, int l) that prints all primes
p, so that s ≤ p ≤ l. It returns the count of primes in this range. This function calls the function
isPrime() to test primality. [You get 50% credit if you write a recursive function.]
4. Call printPrime() from main() with s and l as actual parameters. Also print the prime
count in the range s ≤ p ≤ l from main().
s l primes count
10 18 {11, 13, 17} 3
27 55 {29, 31, 37, 41, 43, 47, 53} 7


Operations on Number

Problem Statement
int sumdigits (int num) : This function should take a decimal number as input and return the sum of digits
of the number.
2. int reverse (int num) : This function should take a decimal number and return the reverse number.
3. int palindrome (int num) : This function should return 1 if the input decimal number is a palindrome and
0 otherwise.
4.  void findcommondigits (int num1, int num2) : This function should print the digits that are
common in two decimal numbers num1 and num2.
a. [Helper function] int occursdigit (int digit, int num) : This function checks if digit (0<=digit<=9) is
a digit in the decimal number num1
Type the following C program to test the above functions :

Combination of Money for desired money

Problem Statement
write a c program to first take input from user,then print all the combination of money that can lead to the same sum given by user

Metrics Multiplication of two Metrics

Problem Statement 
Write a c program to scan two metrics using scanf function
multiply these metrics if possible
print the result

Finding Largest nondecreasing sequence in an array

Problem Statement
Write a c programme to find out largest not decreasing sequence in an array