Skip to main content

Posts

Showing posts from 2019

Binary Search Tree in Java implementation (reference based, dynamic memory)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 import java.util.Scanner ; class BST { static BST . Node root = null ; public void insert ( int num ) { if ( root == null ) { root = new BST . Node ( num ); } else { // root node is not empty BST . Node temp = root ; while ( temp != null ) { if ( num <= temp . getVal ()) { if ( temp . getLeft () != null ) temp = temp . getLeft ();

Binary Search Tree in C++( dynamic memory based )

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 #include<bits/stdc++.h> using namespace std; struct bst { int val; bst * left, * right; }; bst * root = nullptr; void srch ( int num,bst * head) { if (head == nullptr){ cout << " \n Number is not present \a " << endl; return ; } if (head -> val == num) { cout << " \n Number is present \n\a " ; return ; } else { if (num < head -> val) srch(num,head -> left); else srch(num,head -> right);

Python program to find Sexy primes

a,b=input("Enter the Range Seprated by space ->" ).split(' ') primes=list() for i in range(int(a),int(int(b)+1)):     flag=1     for j in range(2,i):         if i%j==0:             flag=0             break     if flag==1:         primes.append(i) count=0 for j in primes:     if j+6 in primes:         count+=1 print(count). example: 4 40 output 7

Python program to extract all possible Substring from a given String

1 2 3 4 5 6 7 8 9 10 s = input ("Enter the String->") subs = [] for i in range ( 1 , len (s) + 1 ): for k in range ( 1 ,i + 1 ): j = 0 while (j + k) <= len (s): if s[j:k + j] not in subs: subs . append(s[j:k + j]) j += 1 print (subs) Input: vastgk Output: ['v', 'a', 's', 't', 'g', 'k', 'va', 'as', 'st', 'tg', 'gk', 'vas', 'ast', 'stg', 'tgk', 'vast', 'astg', 'stgk', 'vastg', 'astgk', 'vastgk']

Android :Edittext Format space after Each 4 digit/Character

Replace EditText with your EditText Variable 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 EditText . addTextChangedListener ( new TextWatcher () { byte count1 = 0 ; byte count2 = 0 ; @Override public void beforeTextChanged ( CharSequence s , int start , int count , int after ) { count1 = ( byte ) s . length (); } @Override public void onTextChanged ( CharSequence s , int start , int before , int count ) { count2 = ( byte ) s . length (); } @Override public void afterTextChanged ( Editable s ) { String initial = EditText . getText (). toString ();

Download pocket tank delux with 295 weapons free total 295 weapons version 1.6

Download Pocket Tanks Deluxe Full Version Free With 295 Weapons Pack | Size: 30MB UPDATED 2019 /19/april Description: Pocket Tanks is a 1-2 player computer game for Windows and Mac OS X, created by Blitwise Productions, developer of Super DX-Ball and Neon Wars. Adapted from Michael Welch's earlier Amiga game Scorched Tanks, this newer version features modified physics, dozens of weapons ranging from simple explosive shells to homing missiles, and the ability to move the tank. It supports several expansion packs. At the moment, players can have up to 295 different weapons total. Pocket Tanks is often abbreviated as PTanks. Have Fun! NOTE: FILE NAME IS SCRAMBLED FOR AVOIDING HARD DETECTION & FILE TAKEN DOWN . How to Play: Best with 2 players on the same computer at school or at work. UPDATED LINK https://mirr.re/d/u1Y https://nl26.seedr.cc/ff_get/447027537/ptd16.295.exe?st=lUp-PbRp4YOwToHIOGwStQ&e=1555747979 http://www.uploadmagnet.com/7gfzhbyfe

Comaparison between ParallelSort and Sort in JAVA

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 import java.util.ArrayList ; import java.util.Arrays ; import java.util.Random ; public class sortvsparllelsort { public static void main ( String [] args ) { Random random = new Random (); System . out . println ( "Comparison between Sort and Parallel Sort" ); ArrayList < Integer > arraylist = new ArrayList <>(); for ( long i = 1 ; i < 10000000L ; i ++) { arraylist . add ( random . nextInt ( 900 )); } System . out . println ( "ArrayList has been initialised" ); Integer a []= new Integer [ arraylist . size ()]; Integer b []= new Integer [ arraylist . size ()]; System . out . println ( "Both normal arrays are initialised" ); a = arraylist . toArray ( a ); b = Arrays . copyOf ( a , a . length

JAVA program to Calculate Factorial using Function Interface (involve lambdas )

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 import java.util.Scanner ; import java.util.function.Function ; public class fact { public static void main ( String [] args ) { Function < Integer , String > fact =( n )-> { String res = "Factorial of " + n + " is=" ; double a = 1 ; for ( int i = 1 ; i <= n ; i ++) a *= i ; return res + a ; }; Scanner in = new Scanner ( System . in ); System . out . print ( "Enter the number :" ); int num = in . nextInt (); System . out . println ( fact . apply ( num )); } }

C program to find whether two Strings are cyclic Anagram or not

Example 1.first String: abcd  second string:dabc  output:They are cyclic anagram 2.  first String: abcd  second string:dcab output:They are not  cyclic anagram CODE: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 # include # include int main() { char s[ 100 ], b[ 100 ], temp; int n, len, i; printf( "Enter the String \n " ); scanf( "%s" , s); printf( " \n Entered String=%s" , s); printf( " \n Enter String to be matched->" ); scanf( "%s" , b); printf( " \n Entered String to be matched->%s" , b); len = strlen(s); if (len != strlen(b)) { printf( " \n they are not cyclic anagram \n " ); getchar(); return 0 ; }

Binary to Decimal using Stack in C

CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 #include <stdio.h> #include <stdlib.h> #define SIZE 8 int STACK[SIZE],TOP =- 1 ; int power ( int i) { int res = 1 ; while (i -- ) { res = res * 2 ; } return res; } void push ( int n) { if (TOP == SIZE) printf( "OVerflow" ); else STACK[ ++ TOP] = n; } int pop () { if (TOP ==- 1 ) return - 1 ; else return STACK[TOP -- ]; } void main () { int num,i = 0 ,arr[SIZE],j,res = 0 ,temp; printf( "Enter the number" ); scanf( "%d" , & num); printf( " \n Entered number=%d \n " ,num); while (num) { arr[i ++ ] = num % 10 ; num /= 10 ; } for (j = i - 1 ;j >= 0 ;j -- ) push(arr[j]); for (j = 0 ;j < i;j ++ ) { res = res + (pop() * power(j)); } printf( " \n Result=%d" ,res); getchar