Java Program Of For-each Loop

01. Example: For-each loop apply on string type array. class stringForEachLoop { public static void main(String[] args) { String fruits[] = {"Orange", "Apple", "Mango", "Banana", "Grapes"}; for (String element: fruits) …

Read more

Java Program To Print All Alphabets

01. Example: class printAllAlphabets { public static void main(String args[]) { char alphabet; for (alphabet = 'a'; alphabet <= 'z'; alphabet++) System.out.print(alphabet + " "); System.out.print("n"); for (alphabet = 'A'; …

Read more

Python Program to Implement Intro Sorting

01. Example: def introsort(data): maxdepth = (len(data).bit_length() – 1)*2 introSortingHelper(data, 0, len(data), maxdepth) def introSortingHelper(data, start, end, maxdepth): if end – start <= 1: return elif maxdepth == 0: heapSorting(data, …

Read more

Python Program to Implement Heap Sorting

01. Example: def heapSorting(data): buildMaxHeap(data) for i in range(len(data) – 1, 0, -1): data[0], data[i] = data[i], data[0] maxHeapify(data, index=0, size=i) def parent(i): return (i – 1)//2 def left(i): return …

Read more