473,378 Members | 1,378 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,378 software developers and data experts.

Number of machine instructions generated by code

Hello, everyone. I recently took a class on Data Structures in C++
(using D.S. Malik's C++ Programming: Program Design Including Data
Structures), and while I learned a good about specific data
structures, I felt that the class was a little too rushed and sparse
for my liking. I passed the class with flying colors, but I think it
would be hard for anyone not to do so. I decided to pick up Robert
Sedgewick's Algorithms in C++ 3rd edition to get a better
understanding of the structures and their algorithms

So I am reading through the introduction and I find a few of the
exercises a little annoying. They either seem extremely vague in what
they are expecting, or else they reference a term not decribed in the
previous text is. I know what an "edge" on a tree is because of my
data structures course, but for a book stating that it is "not just
for programmers and computer-science students" I think it would ease
into the subject matter a little better.

Then I run into something that stumps me - there are a few exercises
asking the minimum and/or maximum number of machine instructions
produced by example programs. Maybe I have completely misunderstood
the language, but I thought that C++ produces a different number of
machine instructions based on the computer platform it is on due to
the fact that it is a high level language. Am I completely mistaken?
Is this something I should know?
Jan 9 '08 #1
2 1902
ju*******************@gmail.com wrote:
Hello, everyone. I recently took a class on Data Structures in C++
(using D.S. Malik's C++ Programming: Program Design Including Data
Structures), and while I learned a good about specific data
structures, I felt that the class was a little too rushed and sparse
for my liking. I passed the class with flying colors, but I think it
would be hard for anyone not to do so. I decided to pick up Robert
Sedgewick's Algorithms in C++ 3rd edition to get a better
understanding of the structures and their algorithms

So I am reading through the introduction and I find a few of the
exercises a little annoying. They either seem extremely vague in what
they are expecting, or else they reference a term not decribed in the
previous text is. I know what an "edge" on a tree is because of my
data structures course, but for a book stating that it is "not just
for programmers and computer-science students" I think it would ease
into the subject matter a little better.
Just out of curiosity: Does Sedgewick define what he understands under a tree?
If he stated that he sees trees as directed graphs with special properties, I
wouldn't take offense at the word 'edge'.
Then I run into something that stumps me - there are a few exercises
asking the minimum and/or maximum number of machine instructions
produced by example programs. Maybe I have completely misunderstood
the language, but I thought that C++ produces a different number of
machine instructions based on the computer platform it is on due to
the fact that it is a high level language. Am I completely mistaken?
Is this something I should know?
I believe that there actually is some kind of misunderstanding there. Sedgewick
is almost surely not talking about C++ but his own pidgin programming language.
In this language were are only interested in the number of atomic operations
(whichever Sedgewick consideres atomic) that are needed to fulfill a certain
task. If you count how many copy operations, comparison operations and branching
operations are needed, you'll almost surely be on the safe side (some of these
operations may be optimized away by a real compiler, but this is not relevant in
theoretical computer science). Anyway, I believe that you only should determine
the asymptotic run-time behaviour.

Regards,
Stuart
Jan 9 '08 #2
In article <6a527a0b-7b67-4283-8c43-
8e**********@i29g2000prf.googlegroups.com>,
ju*******************@gmail.com says...
Hello, everyone. I recently took a class on Data Structures in C++
(using D.S. Malik's C++ Programming: Program Design Including Data
Structures), and while I learned a good about specific data
structures, I felt that the class was a little too rushed and sparse
for my liking. I passed the class with flying colors, but I think it
would be hard for anyone not to do so. I decided to pick up Robert
Sedgewick's Algorithms in C++ 3rd edition to get a better
understanding of the structures and their algorithms
Big mistake!
So I am reading through the introduction and I find a few of the
exercises a little annoying. They either seem extremely vague in what
they are expecting, or else they reference a term not decribed in the
previous text is. I know what an "edge" on a tree is because of my
data structures course, but for a book stating that it is "not just
for programmers and computer-science students" I think it would ease
into the subject matter a little better.
IMO, nearly every other book in earth is written better than this one.
Then I run into something that stumps me - there are a few exercises
asking the minimum and/or maximum number of machine instructions
produced by example programs. Maybe I have completely misunderstood
the language, but I thought that C++ produces a different number of
machine instructions based on the computer platform it is on due to
the fact that it is a high level language. Am I completely mistaken?
Is this something I should know?
You're right and it's wrong -- it's asking for something that's
indeterminate, and you should only rarely care about anyway. From a
viewpoint of writing C++ you should generally have at least a vague idea
of the relative speed of basic operations on different types of
operands, and then look at how many operations are needed to carry out a
particular algorithm. Trying to express this as a number of instructions
executed, however, is generally an exercise in pointless frustration.
Your chances of figuring the number of instructions correctly is
minimal, and even if you did it wouldn't mean anything. A modern
processor can typically execute instructions in parallel if they don't
have data dependencies, so the number of instructions is only loosely
related to speed anyway.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jan 14 '08 #3

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

Similar topics

8
by: Joe Wong | last post by:
Hi, I need to implement a unique number generator that 1 or more processes on same or different machines will make use of it. Is there any library / project available already for this? Thanks...
1
by: Robert McLay | last post by:
I'm trying to understand bytecodes generated on different machines. I understand that the bytecodes can change between version. But since I'm told that .pyc files are version dependent but not...
43
by: Minti | last post by:
Hi there everybody, I was just wondering that too many people choose to use language like Java because of its architecture independence, this AI is achieved because Java is as such a...
8
by: ben | last post by:
hello, i'm trying to answer a "prove an upper bound on the number of machine instructions required to process M connections on N objects" exercise from an algorithms book. i don't understand a...
7
by: Philippe Poulard | last post by:
Hi, RefleX 0.1.3, a general-purpose XML Virtual Machine, is available here : http://reflex.gforge.inria.fr/ In this release, you'll find tutorials for mapping SQL to arbitrary complex XML...
74
by: aruna.mysore | last post by:
Hi all, I have a simple definitioin in a C file something like this. main() { char a; ....... int k; }
10
by: coaassign | last post by:
Hi all I need to get a count the no of instructions executed in a for loop in exactly one second... Can any one please give me the code for this... THANKS IN ADVANCE
63
by: deepak | last post by:
Hi, Can someone give the standard function which can create positive integer value in C? Thanks, Deepak
8
by: MisterE | last post by:
Is it possible to create a pointer to a function, and then get its size (the actual size the function takes in machine code), such that you can copy the function to another memory location. You...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.