473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Is it possible to perform CRC checks on Linked Lists?

Hello... I'm wondering if it is possible to perform a CRC or Checksum on the
data contained in a simple Linked List that uses pointers to nodes???
Nov 13 '05 #1
5 2340
"Susanne Strege" <su**********@nasa.gov> writes:
Hello... I'm wondering if it is possible to perform a CRC or Checksum on the
data contained in a simple Linked List that uses pointers to nodes???


Yes.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 13 '05 #2
Susanne Strege wrote:

Hello... I'm wondering if it is possible to perform a CRC or Checksum on the
data contained in a simple Linked List that uses pointers to nodes???


Yes. Are you having trouble doing this in C?

--
Er*********@sun.com
Nov 13 '05 #3
I'm having trouble finding out how to get a valid running checksum without
having to perform a checksum on the entire list each time a new node is
added to the list. This running checksum would then have to match with the
checksum performed on the entire list in the case of a system crash.
CRCWholeList == CRCRunning.

If I performed a checksum on the data contained in each node and then added
them up would the order matter? i.e... CRC(node 1) + CRC(node 2) + CRC(node
3) == CRC(node 3) + CRC(node 2) + CRC(node 1)

"Eric Sosman" <Er*********@sun.com> wrote in message
news:3F***************@sun.com...
Susanne Strege wrote:

Hello... I'm wondering if it is possible to perform a CRC or Checksum on the data contained in a simple Linked List that uses pointers to nodes???


Yes. Are you having trouble doing this in C?

--
Er*********@sun.com

Nov 13 '05 #4

A: Because it's confusing.

Q: Why do people object to top-posting?

[Top-post corrected in the quoted material.]

Susanne Strege wrote:
"Eric Sosman" <Er*********@sun.com> wrote in message
news:3F***************@sun.com...
Susanne Strege wrote:

Hello... I'm wondering if it is possible to perform a CRC or Checksum on the data contained in a simple Linked List that uses pointers to nodes???
Yes. Are you having trouble doing this in C?

I'm having trouble finding out how to get a valid running checksum without
having to perform a checksum on the entire list each time a new node is
added to the list. This running checksum would then have to match with the
checksum performed on the entire list in the case of a system crash.
CRCWholeList == CRCRunning.

If I performed a checksum on the data contained in each node and then added
them up would the order matter? i.e... CRC(node 1) + CRC(node 2) + CRC(node
3) == CRC(node 3) + CRC(node 2) + CRC(node 1)


For a checksum, it's easy because addition is commutative
and associative: When you add up the first three natural numbers
it doesn't matter whether you compute (1+2)+3 or 1+(2+3) or even
(3+1)+2; you get the same sum anyhow. So if you've added up all
the data items in an existing list and obtained the checksum X,
when you tack on a new item with the value 42 the new checksum
is X+42. Furthermore, the new checksum is X+42 no matter where
the new item is added: at the end, at the beginning, or somewhere
in the middle. (For extra credit, what would the new checksum be
if you *removed* an item whose value was 42? For extra extra
credit, what would the new checksum be if you neither inserted
nor deleted an item, but changed the value in an existing item
from 42 to 31?)

For CRC it's trickier, because the CRC operation is neither
commutative nor associative (this is intentional; you want 1/2/3
to produce a different CRC than 1/3/2). However, if the new item
is always added at the end of the list things are tractable. Take
a look at how you're computing the CRC: You initialize with some
value X0, and then incorporate the first item with X1 = f(X0,I1).
Then you do X2=f(X1,I2), X3=f(X2,I3), ..., Xn=f(X[n-1],In) and
hand back Xn as the CRC. If there'd been n+1 items you'd have
gone through exactly the same sequence of steps and gotten exactly
the same results, except you'd have also done X[n+1]=f(Xn,I[n+1]).
So if you remembered the CRC (Xn) from before, you need only one
more step to compute the new CRC (X[n+1]). Handling deletions at
the end shouldn't be too difficult. Handling insertions and
deletions at the front of the list might be possible; I haven't
really studied it. Handling insertions and deletions at arbitrary
positions in the list looks daunting.

So, with this much outline: Are you having trouble expressing
this in C?

--
Er*********@sun.com
Nov 13 '05 #5
On Wed, 1 Oct 2003 13:12:31 -0400, "Susanne Strege" <su**********@nasa.gov>
wrote:
I'm having trouble finding out how to get a valid running checksum without
having to perform a checksum on the entire list each time a new node is
added to the list. This running checksum would then have to match with the
checksum performed on the entire list in the case of a system crash.
CRCWholeList == CRCRunning.
This is possible.
If I performed a checksum on the data contained in each node and then added
them up would the order matter? i.e... CRC(node 1) + CRC(node 2) + CRC(node
3) == CRC(node 3) + CRC(node 2) + CRC(node 1)


See now, you're talking about two different things.

A CRC (cyclic redundancy check) is not the same as a simple checksum.

A CRC would be sensitive to the order in which the data was processed; a
checksum would not be.

Google on "CRC algorithm" for more information.

--
Robert B. Clark (email ROT13'ed)
Visit ClarkWehyr Enterprises On-Line at http://www.3clarks.com/ClarkWehyr/
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kakarot | last post by:
I'm gona be very honest here, I suck at programming, *especially* at C++. It's funny because I actually like the idea of programming ... normally what I like I'm atleast decent at. But C++ is a...
7
by: Chris Ritchey | last post by:
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am...
10
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy...
1
by: Booser | last post by:
// Merge sort using circular linked list // By Jason Hall <booser108@yahoo.com> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //#define debug
3
by: s_subbarayan | last post by:
Dear all, 1)In one of our implementation for an application we are supposed to collate two linked lists.The actual problem is like this: There are two singularly linked lists, the final output...
4
by: MJ | last post by:
Hi I have written a prog for reversing a linked list I have used globle pointer Can any one tell me how I can modify this prog so that I dont have to use extra pointer Head1. When I reverse a LL...
12
by: joshd | last post by:
Hello, Im sorry if this question has been asked before, but I did search before posting and couldnt find an answer to my problem. I have two classes each with corresponding linked lists, list1...
19
by: Dongsheng Ruan | last post by:
with a cell class like this: #!/usr/bin/python import sys class Cell: def __init__( self, data, next=None ): self.data = data
51
by: Joerg Schoen | last post by:
Hi folks! Everyone knows how to sort arrays (e. g. quicksort, heapsort etc.) For linked lists, mergesort is the typical choice. While I was looking for a optimized implementation of mergesort...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.