Showing posts with label Computer Programming. Show all posts
Showing posts with label Computer Programming. Show all posts

Wednesday, 30 December 2020

Learning Data Structures and Algorithms with Ease

data structures and algorithms

Learning Data structures and Algorithms With Ease

 

Hello Guys, hope you all are fine. Today I came with a solution to a very crucial issue to all of students of software or computer science students that is of “Learn Data Structures and Algorithms”. So Let’s Start Today.

Get Rid of Afraid:

Most of the students have some kind of phobia from data structures, that comes in their mind by listening to someone that “Learning of Data Structure” is difficult. so, first of all, you should get rid of your afraid.

 Make Notes:

When Professor is delivering you the lecture, so you should note down headings on-page, so that you should research that topic at another time and you can easily step toward the learning of data structure and algorithm with ease.

Search for a topic:

After Making notes you arrive at a safe place and search for that topic in a book, internet or ask from professor until you got the topic clear. This step is one of the most important tips in learning data structure and algorithm and by that, you will not forget a topic at all.

Search Problems to Solve it:

When you got the topic so you should search for a problem(Means a program statement that should be solved by you) on the internet or in the book. Write it on a page. By this you can practice data structure and algorithm

Do Brainstorming or Mind Mapping on it:

Then you should brainstorm or do mind mapping on that specific topic so that you get to know how much you learned. if you got an idea so that’s okay you should implement it in a language. Otherwise, you should search on the internet for its solution. This can help you how to find solutions to tasks in data structure and algorithm.

“Practice Makes a Man Perfect”:

There is a proverb practice makes a man perfect, means how much you do practice on that topic so you will become more and more perfect. A solution to learn data structure and algorithm with ease.

Give a Revision:

Give a Revision after 1 week from the day you learned so that you never forgot the topic. it can give you to not forget the data structure and algorithm that you already learned.

Here I had told you how to learn data structure. in the next article, I will tell you which sources you should use to lean data structures and algorithms. 

How to get started with Machine Learning

  • Introduction
  • What is ML(Machine Learning)?
  • Problems to Learn Machine Learning
  • Steps to get started with Machine Learning or ML
    • Learning Python
    • Reading Hands-On Machine Learning
    • Udemy Paid Course
  • Conclusion

Introduction

                    Hello Readers, Hope you are doing well. Today we are talking about "How to get started with machine learning", means how to enter in machine learning field and make machine more intelligent. So lets start today.

What is ML(Machine Learning)?


                    Before going forward we must know "what is machine learning?" there are thousands of definitions of machine leaning but for beginner in simple words it can be "to code in away so that make machine  intelligent and then machine perform a task without any user involvement".

Problems to Learn Machine Learning

                    Mostly all of students are confused from where machine learning to be started, because there are no of platforms and books available to learn machine learning. so Learning Machine Learning is got difficult but in reality it isn't.

Steps to get started with Machine Learning or ML

     Learning of Python: 

                    To get started with machine learning you must have to learn python first. Their are thousands of python courses available but I would only prefer UDEMY Course as shown in picture and link is https://www.udemy.com/course/complete-python-bootcamp/
Udemy Python Paid Course
Note: Bootcamp give more benefit to Beginner, but if you are out of money so you can join their free course
Udemy Python Free Course
                    Link is: https://www.udemy.com/course/pythonforbeginnersintro/ which can be studied by you, but not got got certificate at all.

    Reading Hands-On Machine Learning 

                    Readers to get start with machine learning so I think there is no other book instead of it. It cover all basics of machine learning and then move on to advanced. It is freely available on PdfDrive the link is https://www.pdfdrive.com/hands-on-machine-learning-with-scikit-learn-and-tensorflow-concepts-tools-and-techniques-to-build-intelligent-systems-e168440497.html

    Udemy Paid Course

                        You should register to udemy course link is https://www.udemy.com/course/machinelearning/ which is a paid course but you would experience a lot. There is free version as well link is https://www.udemy.com/course/machine-learning-data-science-foundations-masterclass/

Note: Free courses can not benefit you a lot but if you are out of money so you can go through with it 

Conclusion

                        To get started with machine learning we discussed that we must go through few books and few courses of UDEMY. You should go through with these and See on next Blog.

How to Build Logic in Computer Programming


  1. Read Problem 
  2. Understand Problem 
  3. Do Mind Mapping 
  4. Need Help?
  5. write Dummy code on page
  6. Test Dummy Data
  7. Update Code

 Hi Programmers!

I hope so you would be fine. Today i had come with idea such that how to build logic to solve any task in any of programming language such as in C#, C, C++, Python, JAVA and Many more. For it you should read, understand problem, draw a map in your mind and then build your code here you go the solution.

Read Problem:

First Step that we have to take is to read the problem or task Carefully. For it you should:

  1.  Highlight main point(what is Required) through ballpoint or highlighter.
  2. if Can't Highlight so read the problem for 5 times.

Understand Problem:

Main Points are highlighted in the first step in this step we should do:

  1. Link the important points with each other.
  2. shorter the whole scenario on a page by linking the important points.
After that step we are capable of visualizing the whole scenario in few points. These first two steps are very much important so do it carefully.

Do Mind Mapping:

In that step we visual Summarized Scenario. in that step we do:

  1. Visualize scenario is our mind.
  2. Link that in our mind.
  3. Draw a rough diagram such as how your algorithm will work.

Need Help?:

If you are not capable of even understanding the scenario or you can't visualize the shorter scenario so for it you should take help from:

  1. Sub-Conscious Mind: Be focused on mind and think about that problem.
  2. Internet
  3. Professor or Teacher

Write Dummy Code in Rough Page:

From step 3 and 4 what comes in your mind write dummy code on your page. Use comments for why that line of code is included.

Test Dummy Data:

Test the Written code or Algorithm through Dummy Data and through Different Aspects. If on all Aspects the output is come correct so your algorithm is right otherwise do step 7.

Update Code:

in Which aspect you fail analyze that by putting your eyes on line of code and comments. note that changes and repeat step 6,7 and 8.

Diagram:

how to build logic


 By following all of these steps you will be capable to solve any of complex task but you will need more and more practice,  "because Practice makes man Perfect".

Monday, 28 December 2020

Function Templates (Object Oriented Programming Using C++).

 

Function Templates 


Objectives:  

To familiarize students with function templates and its usage      

Tools:

Turbo C++ IDE 

Procedure:

  Writing C++ language program to perform the following tasks
       Template used for an absolute value function
       Template used for function that finds number in an array

Templates: 

 can be used for both classes and functions and a feature, blueprint or formula of C++ programming language that allows functions and classes to operate with generic types. Generic programming is a style of computer programming in which algorithms are written in terms of types tobe-specified-later that are then instantiated when needed for specific types provided as parameters. 
A function template behaves like a function except that the template can have arguments of many different types. In other words, a function template represents a family of functions. Suppose you want to write a function that returns the absolute value of two numbers. As absolute value of a number is its value without regard to its sign: The absolute value of 3 is 3, and the absolute value of –3 is also 3. Ordinarily this function would be written for a particular data type such as:

int abs(int n)          //absolute value of ints
   {
        return (n<0) ? -n : n;     //if n is negative, return -n
    }


In above the function takes one argument and return value of same type but we will have to write a separate function in order to return absolute value of type long such as:

long abs(long n)               //absolute value of longs
    {
         return (n<0) ? -n : n;
     }


The body of the function is written the same way in each case, but they are completely different functions because they return values of different types. So to in order to save our time and to avoid code to rewrite we use function template. The general syntax of function template is as follow:

template <class type> 
     {
                  // Body of function
     }

The template keyword informs compiler that we are using a template function. The keyword class, within the angle brackets, is a type. The “type” is a placeholder name for a data type used by the function. This name can be used within the function definition and is called as template argument.



Step 1: Create New C++ Program File and save it as lab13.cpp Step 2:Write the following code as shown in figures below

function template program

Figure 35(a): Absolute value template function

function template program

Figure 35(b): Absolute value template function

Step 3: Save file again, compile and run it for required output as shown in figure below
function template program output

Figure 35(c): Absolute value template function
Step 4: Override above code with the following as shown in figures below
function template program

Figure 36(a): Number in an array template function

function template program

Figure 36(b): Number in an array template function
Step 5: Save file again, compile and run it for required output as shown in figure below
output

Figure 36(c): Number in an array template function

Try these Task(s): Write C++ language program to perform following tasks

       Define a function template for finding the minimum value contained in an array. Write a main() function to find the minimum value of integer array and minimum value of floating point numbers in an array. 

       Write a template function that returns the average of all the element of an array. The argument to the function should be the array name and the size of the array (type int). In main(), exercise the function with arrays of type int, long, double and char.

       Create a function called swaps() that interchanges the values of the two arguments sent to it. Make the function into a template, so it can be used with all numerical data types (char, int, float, and so on). Write a main() program to exercise the function with several types.


Functions in Computer Programming? (Example In C)

 

            Functions in Computer Programming

Objectives:

  To familiarize students with the function declaration, definition, prototypes, and function call. Also to show values passing as call by value and call by reference. 

Tools:

Turbo C IDE  

Procedure:

 Writing a C Program which will perform the following tasks
 State a function which receives a float and an int from main(), finds the
   product of these two and returns the product which is printed through main().

The function is a block of statements and is calling for specific tasks to be performed in a program. Through function, we can divide the whole program in a module, and thus it will be very easy to deal with modules or small pieces of programs. Any C program contains at least one function, which is main() function. There is no limit on the number of functions that might be present in a C program. Each function in a program is called in the sequence specified by the function calls in main(). After performing tasks by each function, control returns to the main(). The function cannot be defined inside another function

Every function in C programming language should be declared before they are used. These type of declaration are also called function prototype. Function prototype gives compiler information about function name, type of arguments to be passed and return type. The syntax of function prototype is as follow:
Return-type <function-name> (type(1) argument(1),....,type(n) argument(n)); For example:
     int add(int a, int b);
In the above example, int add(int a, int b); is a function prototype which provides following information to the compiler: 
       return type of the function is int. 
       name of the function is add() 
       two arguments of type int are passed to function. 

Function prototype is not needed if user-definition function is written before main() function.
For a function to perform specific tasks, it must be called or invoked which is called a function call. The function can be called or invoked using the following syntax:
function-name (argument(1),….argument(n));
When a function is invoked using the above syntax, control of the program jump from that statement to function definition and execute the code inside that function.

The function definition contains programming codes to perform specific tasks. The syntax of function definition can be as follows:


return-type function-name
{
                          Block of statements;
}

Call by value is used when called function does not need to modify the value of the caller’s original variable. In this case, a copy of the variable is passed to the function and when the function changes its values then it has no effect on the value of the variable in the main function as shown below:

main function

 
The output of variables a and b won’t change and will be printed as a = 10 and b = 20.

Call by reference means that the compiler will not create a local copy of the variable which you are referencing to. It will get access to the memory where the variable saved. When you are doing any operations with a referenced variable you can change the value of the variable. The address is passed by using the symbol “&” and is received by using the asterisk symbol “*” shown as:

main program and output



The output of variables and changes because it was passed by reference. 

Step 1: Create a New C Program File and save it as lab7.c
Step 2: Write the following code as shown in figures below

c program
 

Figure 20 (a): Product of float and integer using the function

c program
 

Figure 20 (b): Product of float and integer using the function

 Step 3:Save file again, compile and run it for required output as shown in the figure below
   

output

Figure 21: Product of float and integer using the function