Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
H

Hamza Bin Amin

@Hamza Bin Amin
About
Posts
2
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Linked List With Two Three Tree
    H Hamza Bin Amin

    I've to do the searching process through the 2-3 tree by storing the roll number s of the students as keys in the tree. The tree node will contain a pointer to the doubly node in the doubly linked list. I included the doubly node pointer as a private member in the tree node class Then tried to merge the 2-3 tree nodes with the student objects

    // Students Objects

    Node \*s1,\*s2,\*s3,\*s4;
    s1 = new Node;
    s1->data.setData("Hamza",12105092);
    
    s2 = new Node;
    s2->data.setData("Sherlock",12105102);
    
    s3 = new Node;
    s3->data.setData("Watson",12105022);
    
    s4 = new Node;
    s4->data.setData("Spidey",12105042);
    

    // Courses Objects

    Course c1("OOP",3.52,"A");
    Course c2("DM",4,"A+");
    Course c3("DLD",3.2,"A-");
    

    // Tree Creation

    CTree \*tree1;
    

    // Tree Insertion

    tree1 = new CTree();
    tree1->insert(new Student("",12105092));
    tree1->insert(new Student("",12105042));
    tree1->insert(new Student("",12105102));
    tree1->insert(new Student("",12105022));
    

    // Merging Doubly Nodes With 2-3 Tree

    tree1->findOWN(new Student("",12105092))->merge(s1);	
    tree1->findOWN(new Student("",12105102))->merge(s2);	
    tree1->findOWN(new Student("",12105022))->merge(s3);
    tree1->findOWN(new Student("",12105042))->merge(s4);
    

    /************************************

    1. Creating An Empty List Of Students
      ************************************* */

      doublyLinkedList d1;

    /*****************************
    2. Adding Students To The List
    ****************************** */

    d1.insert(s1);
    d1.insert(s2);
    d1.insert(s3);
    d1.insert(s4);
    

    Relevant 2-3 tree methods

    template
    CNode* CTree::findOWN(T*pKey)
    {
    CNode *pNodeFound= 0;
    bool bKeyFound = false;

    search(pKey, &pNodeFound, &bKeyFound);
    if(bKeyFound == true &&
       TCompare(pKey, pNodeFound->getSmallKey()) == EQUAL)
    {
        return pNodeFound;  
    }
    else if(bKeyFound == true &&
            pNodeFound->getSize() == threeNode && 
            TCompare(pKey, pNodeFound->getBigKey()) == EQUAL)
    {
        return pNodeFound;
    }
    else
    {
        return 0;
    } 
    

    }

    template
    int CTree::TCompare(const T* const pT1, const T* const pT2) const
    {
    int iReturnCode = FAILURE;

    if(\*pT1 < \*pT2)
    {
        iReturnCode = LESS;
    }
    else if(\*pT2 < \*pT1)
    {
        iReturnCode = GREATER;
    }
    else
    {
        iR
    
    C / C++ / MFC data-structures css algorithms learning

  • List And iterator
    H Hamza Bin Amin

    We were given a task to use lists and iterators. We were supposed to make them from scratch. I'm done with that. The problems that I'm having are as following: 1. I'm not able to access the list made of Course datatype which is present in each Student instance. Does this mean I need to make an iterator for that course list inside the student class? 2. Similarly since I don't have direct access to The course list so I added the course into the Student list through the student objects not through the iterator. How can I do it through the iterator? 3. Printing of a particular student and his courses is not happening as my iterator made for student only prints out the students, not the courses present in their courselist. How to do that? Here's the code:

    #include
    #include
    using namespace std;

    const int ILLEGAL_SIZE = 1;
    const int OUT_OF_MEMORY = 2;
    const int NO_SPACE = 3;
    const int ILLEGAL_INDEX = 4;
    const int ILLEGAL_REFERNCE = 5;
    const int COURSE_LIMIT_REACHED = 6;

    template
    class ListIterator;

    template
    class OrderedList {

    friend class ListIterator;
    

    private:

    int maxSize;
    int currentSize;
    T \*listArray;
    bool removeAt(int index) {  
    	
    	if(index < 0 || index >= currentSize) throw ILLEGAL\_INDEX;
    
    	else {
    	
    		for(int i=index;i
    

    OrderedList::OrderedList(int size) {

    if(size < 0) throw ILLEGAL\_SIZE;
    
    maxSize = size;
    
    listArray = new T\[maxSize\];
    
    if(listArray == NULL) throw OUT\_OF\_MEMORY;
    
    currentSize = 0;
    

    }

    template
    OrderedList::OrderedList(const OrderedList& copy) {

    maxSize = copy.maxSize;
    currentSize = copy.currentSize;
    
    listArray = new T\[maxSize\];
    for(int i=0;i
    

    const OrderedList& OrderedList::operator= (const OrderedList& assignment) {

    if(this != &assignment) {
    
    	currentSize = assignment.c
    
    C / C++ / MFC question database tutorial learning
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups