Skip to content

pradeexsu/k-ary--Heap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k-ary--Heap

void k_heap() {
    KHeap < int, functor > h(7);
    for (int i = 60; i > 0; i--)
        h.push(rand() % 200);

    h.print();
    h.sort();
    h.print();
}
Ternary Heap Example👇🏻
Binary Heap Example👇🏻

Example

void class_example() {
    struct Comparator {
        bool operator()(const Student & a,
            const Student & b) {
            return a.marks > b.marks;
        }
    };

    KHeap < Student, Comparator > heap(3);
    // example data
    vector < Student > university {
        Student("jhon", 18, 60),
            Student("smith", 21, 80),
            Student("david", 19, 15),
            Student("jos", 20, 94),
            Student("kim", 21, 9),
            Student("tim", 22, 89),
            Student("fin", 20, 70)
    };
    for (Student & each: university) {
        heap.push(each);
        Student::print_header();
        heap.print();
    }
}

About

genralize k-ary Heap Data Structre.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages