Click here to Skip to main content
15,890,186 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to trace a program? Pin
jeron13-Jul-14 5:02
jeron13-Jul-14 5:02 
AnswerRe: How to trace a program? Pin
Stefan_Lang4-Jul-14 0:05
Stefan_Lang4-Jul-14 0:05 
QuestionTBLRD instruction PIC18 Pin
__John_3-Jul-14 1:20
__John_3-Jul-14 1:20 
AnswerRe: TBLRD instruction PIC18 Pin
CPallini3-Jul-14 2:51
mveCPallini3-Jul-14 2:51 
GeneralRe: TBLRD instruction PIC18 Pin
__John_3-Jul-14 4:04
__John_3-Jul-14 4:04 
GeneralRe: TBLRD instruction PIC18 Pin
CPallini3-Jul-14 4:33
mveCPallini3-Jul-14 4:33 
AnswerRe: TBLRD instruction PIC18 Pin
jeron13-Jul-14 4:14
jeron13-Jul-14 4:14 
QuestionLinked List With Two Three Tree Pin
Hamza Bin Amin30-Jun-14 11:06
Hamza Bin Amin30-Jun-14 11:06 
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


C++
// Students Objects
 
	Node<Student> *s1,*s2,*s3,*s4;
	s1 = new Node<Student>;
	s1->data.setData("Hamza",12105092);

	s2 = new Node<Student>;
	s2->data.setData("Sherlock",12105102);

	s3 = new Node<Student>;
	s3->data.setData("Watson",12105022);

	s4 = new Node<Student>;
	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<Student> *tree1;

// Tree Insertion
	
	tree1 = new CTree<Student>();
	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<Student> d1;

/*****************************
2. Adding Students To The List
****************************** */
	
	d1.insert(s1);
	d1.insert(s2);
	d1.insert(s3);
	d1.insert(s4);



Relevant 2-3 tree methods

C++
template<class T>
CNode<T>* CTree<T>::findOWN(T*pKey)
{
    CNode<T> *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<class T>
int CTree<T>::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
    {
        iReturnCode = EQUAL;
    }

    return iReturnCode; 
}



1. Some how the merging's aren't completely right e.g in case where there are two key values in a node then it mixes up the merging when I try to search 12105022 I should be getting "Watson" but I get "Spidey" instead, how to fix that?
QuestionRe: Linked List With Two Three Tree Pin
David Crow2-Jul-14 3:47
David Crow2-Jul-14 3:47 
GeneralRe: Linked List With Two Three Tree Pin
CPallini2-Jul-14 22:58
mveCPallini2-Jul-14 22:58 
AnswerRe: Linked List With Two Three Tree Pin
Stefan_Lang3-Jul-14 23:56
Stefan_Lang3-Jul-14 23:56 
GeneralMessage Closed Pin
30-Jun-14 8:40
Member 1091480330-Jun-14 8:40 
GeneralRe: STAR TREK PROJECT Pin
David Crow30-Jun-14 9:22
David Crow30-Jun-14 9:22 
GeneralRe: STAR TREK PROJECT Pin
jeron130-Jun-14 9:53
jeron130-Jun-14 9:53 
GeneralRe: STAR TREK PROJECT Pin
Richard Andrew x6430-Jun-14 11:20
professionalRichard Andrew x6430-Jun-14 11:20 
GeneralRe: STAR TREK PROJECT Pin
Wes Aday30-Jun-14 12:43
professionalWes Aday30-Jun-14 12:43 
GeneralRe: STAR TREK PROJECT Pin
Richard MacCutchan30-Jun-14 15:51
mveRichard MacCutchan30-Jun-14 15:51 
QuestionUsing a Self Developed Dll in VC++ Pin
Django_Untaken30-Jun-14 2:20
Django_Untaken30-Jun-14 2:20 
AnswerRe: Using a Self Developed Dll in VC++ Pin
Richard MacCutchan30-Jun-14 4:58
mveRichard MacCutchan30-Jun-14 4:58 
AnswerRe: Using a Self Developed Dll in VC++ Pin
Albert Holguin1-Jul-14 9:13
professionalAlbert Holguin1-Jul-14 9:13 
QuestionCross compiling using Eclipse C/C++ CDT Pin
Vijay Rajanna29-Jun-14 16:25
Vijay Rajanna29-Jun-14 16:25 
AnswerRe: Cross compiling using Eclipse C/C++ CDT Pin
CPallini29-Jun-14 21:52
mveCPallini29-Jun-14 21:52 
QuestionWhen to delete a pointer (C++)... Pin
DanielSheets26-Jun-14 5:24
DanielSheets26-Jun-14 5:24 
AnswerRe: When to delete a pointer (C++)... Pin
Chris Losinger26-Jun-14 5:32
professionalChris Losinger26-Jun-14 5:32 
AnswerRe: When to delete a pointer (C++)... Pin
Orjan Westin26-Jun-14 5:47
professionalOrjan Westin26-Jun-14 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.