This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class test{ | |
| static void printArray(int arr[]) | |
| { | |
| int i; | |
| for (i=0; i < arr.length; i++) | |
| System.out.print(" "+arr[i]); | |
| System.out.println(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define N_NODES 4 | |
| /* A B C D | |
| A---B A { 0, 1, 0, 0 } | |
| / \ B { 1, 0, 1, 1 } | |
| / \ C { 0, 1, 0, 1 } | |
| / \ D { 0, 1, 1, 0 } | |
| D-------C | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| struct node | |
| { | |
| int data; | |
| struct node* left; | |
| struct node* right; | |
| }; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| n=100 | |
| count=0 | |
| for i in range(10,n+1): | |
| a=str(i) | |
| count+=a.count('0') | |
| print count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HeapSort { | |
| public static final int max = 11; | |
| public static void main(String[] args){ | |
| int[] toSortArray = new int[max]; | |
| //Required Things | |
| //End | |
| toSortArray[0] = 0; | |
| for(int i = 1; i < max; i++){ | |
| toSortArray[i] = (int) (Math.random()*100); | |
| toSortArray[0]++; //holds the number of values in the array; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Factoring Methods | |
| Algorithm description | |
| 1. Establish n the number whose prime factors are sought. | |
| 2. Compute the remainder r and quotient q for the first prime nxtprime =2 | |
| 3. While n is not prime do (not able to understand) | |
| a. if nxtprime is an exact divisor of n then | |
| (a.1) save nxtprime as a factor f, | |
| (a.2) reduce n by nxtprime. | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Factoring Methods | |
| The smallest divisor of an Integer | |
| Algorithm description | |
| 1. Establish n the integer whose smallest divisor is required. | |
| 2. If n is not odd, then | |
| return 2 as the smallest divisor | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package test; | |
| import java.util.*; | |
| public class Test { | |
| /** | |
| * @param args the command line arguments | |
| */ | |
| public static void main(String[] args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Algorithm description | |
| Establish array a[1...n] to be sorted. | |
| Place upper and lower limits for array on the stack and initialize pointer to top of stack. | |
| While stack is not empty do, | |
| remove upper and lower limits of array segment from top of Stack. | |
| While current segment not reduced to size 1 do, | |
| (b.1) Select the middle element of array segment from stack. | |
| (b.2) Partition the current segment into two with respect to the current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Algorithm description | |
| 1. Establish the array a[1 .. n], and the value sought is x. | |
| 2. Assign the upper and lower variables to the array limits. | |
| 3. While lower < upper do | |
| (a) Compute the middle position of remaining array segment to be searched, | |
| (b) if the value sought is greater than current middle value then | |
| (b.1) adjust lower limit accordingly. | |
| else | |
| (b'.1) adjust upper limit accordingly. | |
| 4. If the array element at lower position is equal to the value sought then |
NewerOlder