## 1 Introduction  
There is a great demand for vehicular ad hoc networks in which vehicles can communicate with each other without any infrastructure. The purpose of these networks is to reduce delays in traffic flow and improve driving quality. These networks have attracted the attention of universities and industries because they can improve road safety and provide many services to drivers and travelers. VANET is the core of an intelligent transportation system (ITS) [1, 2]. It does not require an expensive infrastructure because wireless technology is cheap and ubiquitous. In VANET, when vehicles have a direct connection with each other, they create a vehicle-to-vehicle (V2V) connection. When vehicles interact with roadside units (RSUs), they form a vehicle-to-infrastructure (V2I) connection. Over the past decade, researchers have introduced various methodologies to provide better routing techniques in VANET to avoid road accidents. For example, a vehicle can help other drivers and inform them of an unexpected position so that drivers take appropriate action in response to this event. This attractive feature is very important for making smart cities [3, 4]. View Figure 1. The smart city has no certain definition in the world. However, the motivation to build such a city in different countries is to improve physical, social, and economic infrastructure. In fact, a smart city is created when the city efficiently presents public services provided by the government, increases the quality of services for citizens, and reduces government costs. These programs will not only improve the life quality of citizens but also lead to financial interests for the economy. Today, deploying a smart city requires a safe road that includes road conditions, good mobility, vehicle safety, and easy access to the Internet to provide drivers/passengers services and comfort [5, 6]. Routing is a process for transferring packets between source and destination. In VANET, routing depends on some factors, for example velocity, density, and movement direction [7, 8]. As a result, a challenging problem is to design a routing approach in vehicular ad hoc networks. Thus, traditional routing protocols should be updated for the dynamic environment of VANET [9, 10]. When designing routing protocols in VANETs, some routing challenges include high dynamic topology, frequent disconnections, mobility model, propagation model, communication environment, delay constraint, and quality of service (QoS) requirements. Routing protocols in VANET are categorized as follows: topology-based [11, 12], geographic [12], hybrid [6, 13], clustering-based [6, 14], opportunistic [6, 14], and data fusion [11, 14]. Recently, many scholars are working on the routing challenge in VANET. They have used machine learning (ML) techniques to address the routing challenge in VANET adaptively and independently [15, 16]. Reinforcement learning (RL) is the most efficient ML techniques for deploying routing algorithms in VANET. This algorithm is popular due to the trial and error technique [17, 18]. In reinforcement learning-based routing, the agent discovers the network by taking different actions to earn a routing policy [19, 20]. To achieve this goal, the agent must search for the best path in accordance with several criteria, which are obtained from local information of nodes to reduce energy consumption and improve network connections. However, in order to achieve an optimized routing technique, the agent requires global information about the entire system. In this paper, a \(\mathbf{Q}\)-learning and fuzzy logic-based hierarchical routing algorithm (QFHR) is proposed in VANETs. In the method, the focus is on delay reduction in the routing process. QFHR utilizes a hierarchical routing technique. In this scheme, RSUs use a Q-learning-based routing operation to discover paths between different intersections in the urban environment. In the existing Q-learning-based routing algorithms, researchers often consider vehicles as the state space in Q-learning.