Click here to Skip to main content
15,908,776 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSuitable Application type in VS2008 for my Purpose Pin
manoharbalu6-Jul-14 19:53
manoharbalu6-Jul-14 19:53 
AnswerRe: Suitable Application type in VS2008 for my Purpose Pin
Richard MacCutchan6-Jul-14 20:46
mveRichard MacCutchan6-Jul-14 20:46 
QuestionWinsock Event Select Model Pin
Richard Andrew x645-Jul-14 20:54
professionalRichard Andrew x645-Jul-14 20:54 
AnswerRe: Winsock Event Select Model Pin
jeron17-Jul-14 5:34
jeron17-Jul-14 5:34 
GeneralRe: Winsock Event Select Model Pin
Richard Andrew x647-Jul-14 6:46
professionalRichard Andrew x647-Jul-14 6:46 
GeneralRe: Winsock Event Select Model Pin
jeron17-Jul-14 7:31
jeron17-Jul-14 7:31 
GeneralRe: Winsock Event Select Model Pin
Richard Andrew x647-Jul-14 7:59
professionalRichard Andrew x647-Jul-14 7:59 
AnswerRe: Winsock Event Select Model Pin
Randor 7-Jul-14 7:25
professional Randor 7-Jul-14 7:25 
GeneralRe: Winsock Event Select Model Pin
Richard Andrew x647-Jul-14 7:31
professionalRichard Andrew x647-Jul-14 7:31 
GeneralRe: Winsock Event Select Model Pin
Randor 7-Jul-14 12:19
professional Randor 7-Jul-14 12:19 
GeneralRe: Winsock Event Select Model Pin
Richard Andrew x647-Jul-14 12:22
professionalRichard Andrew x647-Jul-14 12:22 
QuestionArithmetic Operator Overload in Pure Abstract Class Pin
CJ14-Jul-14 11:34
professionalCJ14-Jul-14 11:34 
AnswerRe: Arithmetic Operator Overload in Pure Abstract Class Pin
jschell7-Jul-14 10:10
jschell7-Jul-14 10:10 
AnswerRe: Arithmetic Operator Overload in Pure Abstract Class Pin
Stefan_Lang7-Jul-14 21:43
Stefan_Lang7-Jul-14 21:43 
QuestionRepaint control component question Pin
econy4-Jul-14 4:16
econy4-Jul-14 4:16 
AnswerRe: Repaint control component question Pin
Richard MacCutchan4-Jul-14 5:46
mveRichard MacCutchan4-Jul-14 5:46 
QuestionHow to trace a program? Pin
GwapoKho3-Jul-14 3:02
GwapoKho3-Jul-14 3:02 
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?

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.