コード例 #1
0
ファイル: hashing_function.py プロジェクト: sachin0273/python
def Hash_Function_Driver():
    """

    :return: this function return the hash_list of integers

    """
    try:
        hash_list = []
        for index in range(11):
            hash_list.append(Linked_List(
            ))  # here we creating 10 different object for each slot

        result = File_Int_Reader("data_int_data.txt")
        for number in result:
            space = number % 11
            """ 
            here we adding element to the linked list based on reminder of number using 
            add to start function called from linked list
            """
            hash_list[space].Add_To_Beginning(number)
        while True:
            try:
                number_for_search = int(
                    input(" please enter number for search "))
                if 0 < number_for_search < 1000:
                    element = number_for_search % 11
                    hash_list[element].Search_Element_Add_Or_Delete(
                        number_for_search)  # here we calling function for
                    # search in linked list
                    break
                else:
                    print("please enter number between 1 to 1000")
            except ValueError:
                print("please enter valid input")

        print(hash_list)
        index = 0
        for data in hash_list:
            print("position-->{}".format(index), end=' ')
            data.Display()
            print()
            index += 1
    except FileNotFoundError:
        print("please enter valid file path")
コード例 #2
0
"""

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
purpose: in this program we print the anagram using queue implemented by linked list
author:  Sachin Shrikant Jadhav
since :  28-08-2019
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""

from data_structure.my_linked_list import Linked_List
from data_structure.prime_anagram_array import Prime_Array

"""here we creating object"""
linked = Linked_List()


def Anagram_Queue():
    """

    :return: in this function we print prime anagrams between 1 to 1000 numbers

    """
    try:
        anagrams = Prime_Array()  # here we calling anagram array from prime_anagram.py module

        for i in anagrams[0]:  # here we adding anagram in queue linked list
            linked.Add_To_Beginning(i)  # here we calling function from linked list
        while linked.head.next is not None:  # here we printing anagram from queue
            result = linked.Delete_To_Last_Save()  # calling function from linked list
            print(result, end=" ")