Click here to Skip to main content
16,005,222 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: STL question Pin
Nemanja Trifunovic9-Oct-04 3:57
Nemanja Trifunovic9-Oct-04 3:57 
GeneralRe: STL question Pin
Bob Stanneveld10-Oct-04 2:59
Bob Stanneveld10-Oct-04 2:59 
GeneralRe: STL question Pin
Kevin McFarlane9-Oct-04 4:03
Kevin McFarlane9-Oct-04 4:03 
GeneralRe: STL question Pin
Bob Stanneveld10-Oct-04 2:59
Bob Stanneveld10-Oct-04 2:59 
General8x8 Icon on Button control Pin
Murlai8-Oct-04 21:38
Murlai8-Oct-04 21:38 
GeneralConcurrency Issues & Inline Functions Pin
Ajoy8-Oct-04 19:58
Ajoy8-Oct-04 19:58 
GeneralRe: Concurrency Issues & Inline Functions Pin
Ravi Bhavnani9-Oct-04 6:49
professionalRavi Bhavnani9-Oct-04 6:49 
GeneralDatastructure lab Pin
El_Maco8-Oct-04 18:25
El_Maco8-Oct-04 18:25 
Hi!
I'm a fellow that has big problems Dead | X| on starting this next datastructure lab in c++Cry | :(( . I have so much in my mind right now and I don't know if I'm gonna complete this lab on time.
So i'm wondering if there are someone that could help me with this lab?Rose | [Rose]

We use at the school visual studio 6.0

Here's the lab description:

A) Hash table

Now your going to make an article-storage were the articles will be saved in a hash-table for fast prompt accessible. For every article saves the information of the article-number, article-type and the amount articles in the storage.
You should be able to “hash” on the article-number( i.e article-number is the key). You should be able to ADD, SEEK and LIST the articles in the storage.

The programme shall handle collision with "Separate Chaining” i.e create linked list at collisions. You shall therefore make an array of pointers that initiate to NULL, afterward you should be able to seek and add articles that are missing.

At collision you do your linked list. Use here as said a linked list and a string class.
Remember when you add an article for the first time to the index, you have to move the NULL-pointer to point at the new post and then link the article last in the list.
If an article with that article-number already exist in the list, the numbers on the storage should increase on the one that already existed.
Does’nt the articlename correspond, then you could yourself decide how it’s gonna be solved in your programme.

Assume from these files(must use)
1. Hash.h
2. Hash.cpp
3. Article.h

B) Sorting

This task goes out on that you have to implement 3 optional sorting-algorithms. The algorithms shall be choosed so an algorithm works with O(n2), next with O(n log n) and the last one with O(n).

Write a programme that at random takes number-values to a file. This file shall be used as indata for sorting. After the sorting, shall the result be written out into a result-file. The result-file shall also be used as indata for sorting, to see how the algorithms works on the already sorted or almost sorted data ( if some values changes).

You shall have to create data-files with 5 different quantity of numbers to sort. These values shall be used as indata to respective algorithm. Run the algorithm with indata that is both sorted and unsorted.
You shall use these following numbers: 100 000, 200 000, 400 000, 800 000 and 1 600 000 values. Same computer must be used to check all values to have a more fair result and the computer may not work with other things during the process of the sorting.
Is it so that your computer makes the sorting too quick or too slow, you may have to change some numbers so you get a better result, NOTE that the quantity of the numbers shall double for each sorting.

Every algorithm shall have two variables, compare and swap, that counts how many comparision and copies of values has been made during the sort. These two variables shall be used in comparision between the different algorithms.
Registrate also the time the algorithms take when they are used, by using following class:
1. Timer.h
2. Timer.cpp

Do a table with your results that contains these facts:
• Run with an unsorted and a sorted data
• Values for compare and swap for respective run
• Time-consumption for respective run


Here comes the code for the following files.

1. Hash.h
<br />
#ifndef _HASH_H<br />
#define _HASH_H<br />
<br />
#include "LinkedList.h"<br />
<br />
class Hash<br />
{<br />
public:<br />
	Hash();<br />
	~Hash();<br />
	//... <br />
<br />
private: <br />
	const int TABLESIZE;<br />
	LinkedList *m_table;<br />
};<br />
<br />
#endif<br />


2. Hash.cpp
<br />
#include "Hash.h"<br />
<br />
Hash::Hash() : TABLESIZE(11)<br />
{<br />
	m_table = new LinkedList[TABLESIZE];<br />
}<br />
<br />
Hash::~Hash()<br />
{<br />
	delete[] m_table;<br />
}<br />


3. Article.h
<br />
#ifndef _ARTICLE_H<br />
#define _ARTICLE_H<br />
<br />
#include "String.h"<br />
<br />
class Article<br />
{<br />
public: <br />
	Article(int i_key, int i_number, String i_type);<br />
	//...<br />
<br />
private:<br />
	int m_key;<br />
	int m_number;<br />
	String m_type;	//Använd din strängklass<br />
}; <br />
<br />
#endif<br />


4. Timer.h
<br />
#ifndef TIMER_H<br />
#define TIMER_H<br />
<br />
class Timer<br />
{<br />
public:<br />
	Timer(){ m_startTime = 0; m_stopTime = 0; }<br />
	int startTimer();	//Returnerar 0 om timern inte kunde initieras<br />
	double stopTimer();	//Returnerar tiden (ms) som förlöpt mellan start och stop<br />
<br />
	double getTime();	//Hämtar sista tidtagningen i millisekunder<br />
private:<br />
<br />
	double m_startTime;<br />
	double m_stopTime;<br />
	double m_frequence;<br />
};<br />
<br />
#endif<br />


5. Timer.cpp
<br />
<br />
#include <windows.h><br />
#include "timer.h"<br />
<br />
<br />
int Timer::startTimer()<br />
{<br />
	LARGE_INTEGER start, freq;<br />
	if(!QueryPerformanceFrequency(&freq))<br />
		return 0;<br />
	m_frequence = (double) freq.QuadPart;<br />
	QueryPerformanceCounter(&start);<br />
	m_startTime = (double)start.QuadPart;<br />
	return 1;<br />
}<br />
<br />
double Timer::stopTimer()<br />
{<br />
	LARGE_INTEGER end;<br />
	QueryPerformanceCounter(&end);<br />
<br />
	m_stopTime = (double)end.QuadPart;<br />
<br />
	return (m_stopTime-m_startTime) * 1000.0 / m_frequence;<br />
}<br />
<br />
double Timer::getTime()<br />
{<br />
	return (m_stopTime-m_startTime) * 1000.0  / m_frequence;<br />
}<br />


That's all. You can send me the programme by mail if you finished the lab. That would be awesome!Big Grin | :-D

THANK U ALL!Rose | [Rose]
GeneralRe: Datastructure lab Pin
Ravi Bhavnani9-Oct-04 6:44
professionalRavi Bhavnani9-Oct-04 6:44 
GeneralRe: Datastructure lab Pin
Henry miller11-Oct-04 3:43
Henry miller11-Oct-04 3:43 
QuestionHow to code to stop a printer driver? Pin
DengJW8-Oct-04 17:56
DengJW8-Oct-04 17:56 
Generalfast GDI drawing Pin
ashxly8-Oct-04 17:14
ashxly8-Oct-04 17:14 
GeneralRe: fast GDI drawing Pin
-_- KIN~9-Oct-04 5:53
suss-_- KIN~9-Oct-04 5:53 
Generalpushbutton code Pin
jpfletcher8-Oct-04 16:33
jpfletcher8-Oct-04 16:33 
GeneralRe: pushbutton code Pin
Bob Stanneveld8-Oct-04 21:38
Bob Stanneveld8-Oct-04 21:38 
GeneralRe: pushbutton code Pin
toxcct9-Oct-04 0:26
toxcct9-Oct-04 0:26 
GeneralCrystal reports Pin
RADSGR8-Oct-04 15:35
RADSGR8-Oct-04 15:35 
GeneralWaitForMultipleObjects() error Pin
Anonymous8-Oct-04 14:56
Anonymous8-Oct-04 14:56 
GeneralRe: WaitForMultipleObjects() error Pin
Bob Stanneveld8-Oct-04 21:41
Bob Stanneveld8-Oct-04 21:41 
GeneralRe: WaitForMultipleObjects() error Pin
Anonymous11-Oct-04 7:01
Anonymous11-Oct-04 7:01 
Generalgenerate blue screen of death Pin
Member 1855338-Oct-04 14:20
Member 1855338-Oct-04 14:20 
GeneralRe: generate blue screen of death Pin
Michael Dunn9-Oct-04 6:20
sitebuilderMichael Dunn9-Oct-04 6:20 
GeneralDialog app - menu Pin
Andre Massada8-Oct-04 12:24
Andre Massada8-Oct-04 12:24 
GeneralRe: Dialog app - menu Pin
Andrzej Markowski8-Oct-04 20:43
Andrzej Markowski8-Oct-04 20:43 
Generalseekin help fr voip application Pin
amitranjanmishra8-Oct-04 11:47
amitranjanmishra8-Oct-04 11: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.